2011-08-30 53 views
0

没有人知道为什么当我加入...的OBJ-C的initWithCoder似乎崩溃NavigationController

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

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

return self; 

}

我RootViewController的使用didSelectRowAtIndexPath方法也不会从一个表格单元格推一个新的观点方法。这是它似乎挂起的线...

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

我没有得到任何错误消息,它只是似乎跳过它。除非我把initWithCoder拿出来,它工作正常。

任何洞察力将appriciated。

Chris

回答

1

你不调用父类的实现-initWithCoder:

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

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

    return self; 
} 
+0

假设超级采用'NSCoding' ...... – justin

+0

“我的RootViewController的”似乎意味着该类从UIViewController的继承,不是吗? –

+0

在这种情况下安全的假设:) – justin

0

检查日志并查找抛出的异常,导致代码过早终止。或者在NSException提高时设置一个中断。

顺便说一句,你需要调用[超级初始化]中的initWithCoder: