0
奇怪的行爲這裏是從我的應用程序代碼:用的NSMutableArray
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);
}
}
兩個考勤語句(其是用於NSLog的一個宏)轉儲存在於firstPhotoVoters和secondPhotoVoters陣列的陣列元素。但是,在for循環中,兩個數組都顯示爲空。 firstPhotoVoters.count始終爲零。我在這裏錯過了什麼?
謝謝。
您剛剛清空了陣列,然後記錄下來。它應該在if語句之外。 – Mikael
這是我所犯過的最愚蠢的錯誤。謝謝Mikael。 –
它發生在我們所有人:)好吧,如果我發佈它作爲答案? – Mikael