我已将此代码添加到项目中的“MasterViewController.m”中:
- (void)encodeWithCoder:(NSCoder *)encoder {
[encoder encodeObject:_savedText forKey:@"savedText"];
}
。
- (id)initWithCoder:(NSCoder *)decoder {
if((self = [super init])) {
_savedText = [decoder decodeObjectForKey:@"savedText"];
}
return self;
}
当我添加“initWithCoder-code”时,导航标题消失,而当我在导航栏中单击“添加按钮”时,应用程序崩溃。
(_savedText”是mutableArray)是什么原因引起的?
最佳答案
不要调用[super init]
。改为调用[super initWithCoder:]
。
关于xcode - Xcode NsCoding导航标题消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28196287/