NSMutableArray 调用 addObject 方法后仍然为 null
[_noteTitles addObject:@"title"];
[_noteDescriptions addObject:@"description"];
[self.tableView reloadData];
NSLog(@"%@", [_noteDescriptions description]);
NSLog(@"%@", [_noteTitles description]);
在这些行之前,我合成了“_noteDescription”和“_noteTitles”。当 NSLog 行被调用时,在控制台上我得到两个数组的“(null)”。该函数将被多次调用(不是太频繁)来更新表的内容,但现在数组还没有被填充。
[_noteTitles addObject:@"title"];
[_noteDescriptions addObject:@"description"];
[self.tableView reloadData];
NSLog(@"%@", [_noteDescriptions description]);
NSLog(@"%@", [_noteTitles description]);
Before those lines I synthesized both "_noteDescription", "_noteTitles." When the NSLog lines are called, on the console i get "(null)" for both arrays. This function will be called multiple times (not too often) to update the contents of a table, but right now the arrays are not getting populated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来您没有初始化数组。因此,您将
addObject:
发送到nil
并且没有任何反应。这也解释了为什么NSLog()
打印(null)
。请注意,
@synthesize
会生成属性的访问器,但它不会初始化支持实例变量。It looks like you did not initialize your arrays. Therefore, you are sending
addObject:
tonil
and nothing happens. This also explains whyNSLog()
prints(null)
.Note that
@synthesize
generates the accessors for your property, it does not initialize the backing instance variable.