以下是我的应用程序中的代码:
NSMutableArray *firstPhotoVoters = post.firstPhotoVoters;
NSMutableArray *secondPhotoVoters = post.secondPhotoVoters;
ALog(@"First voters: %@", firstPhotoVoters);
ALog(@"Second voters: %@", secondPhotoVoters);
for (Post* _post in posts) {
if ([_post.objectId isEqualToString:post.objectId]) {
[_post.firstPhotoVoters removeAllObjects];
[_post.secondPhotoVoters removeAllObjects];
ALog(@"Count: %d", firstPhotoVoters.count);
ALog(@"Updated post: %@", _post);
}
}
两个ALog语句(NSLog的宏)转储firstPhotoVoters和secondPhotoVoters数组中存在的数组元素。但是,在for循环中,两个数组看起来都是空的。 firstPhotoVoters.count始终为零。我在这里缺少什么?
谢谢。
答案 0 :(得分:0)
你刚刚清空了数组然后你就记录了它。它应该在if语句之外。