我有一個循環,工作正常,第一次通過,但通過第二次循環時,我得到:應用程序通過循環與nsnull計數崩潰的第二次運行
-[NSNull count]: unrecognized selector sent to instance 0x3a094a70
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull count]: unrecognized selector sent to instance 0x3a094a70'
這裏是我的代碼部分在那裏,我知道它崩潰(最後一行):
...
NSLog(@"dict::%@",dictForPost);
// collect the photo urls in an array
photosInDict = [NSArray array];
// photos is an array of dictionaries in the dictionary
photosInDict = dictForPost[@"photos"];
if (photosInDict.count) {
....
我知道,當photosInDict可是沒有圖片在DIC崩潰,但我不明白爲什麼,因爲我開始它上面的陣列。
我認爲,因爲它是在if語句的條件下崩潰,我需要保護if以及Martin R如何顯示。除非if語句在第一個條件不滿足時退出? – BluGeni
我的'if'語句可以正常工作。如果上半場是假的,下半場將不會被評估。這被稱爲短路評估,所有基於C語言(以及其他許多語言)都使用它。 – rmaddy
哦,我不知道,謝謝你教我。 – BluGeni