开发者

Obj-c initWithCoder seems to crash NavigationController

does anyone know why when i add...

-(id) initWithCoder: (NSCoder *) decoder {

    OutputDataMutableArray = [[decoder decodeObjectForKey:@"RootViewControllerPostArray"] retain];

    return self;

}

to my RootViewController it will not push a new view from a table cell using the didSelectRowAtIndexPath method. This is the line it seems to hang on...

[[self navigationController] pushViewController:postController animated:YES]; 

i get no error messages, it just seems to skip it. Unless i take the initWithCoder out and it 开发者_开发百科works fine.

any insight would be appriciated.

Chris


You’re not calling the superclass’s implementation of -initWithCoder:.

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];

    if(self)
    {
        OutputDataMutableArray = [[decoder decodeObjectForKey:@"RootViewControllerPostArray"] retain];
    }

    return self;
}


Check the log and look for exceptions being thrown causing your code to terminate prematurely. Or set a break on NSException raise.

BTW, you need to be calling [super init] in initWithCoder:

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜