我剛開始學習IOS的開發。每次我運行這個程序時,控制檯並不總是顯示我的NSLog。Xcode,爲什麼在控制檯中省略了一些NSLog條目?
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
NSMutableArray *items = [[NSMutableArray alloc] init];
[items addObject:@"One"];
[items addObject:@"Two"];
[items addObject:@"Three"];
[items insertObject:@"zero" atIndex:0];
NSLog(@"Object at 0 is %@", [items objectAtIndex:0]);
NSLog(@"Object at 1 is %@", [items objectAtIndex:1]);
NSLog(@"Object at 2 is %@", [items objectAtIndex:2]);
NSLog(@"Object at 3 is %@", [items objectAtIndex:3]);
for (int i = 0; i < [items count]; i++) {
NSLog(@"%@", [items objectAtIndex:i]);
}
items = nil;
}
return 0;
}
我應該在控制檯我每次運行它時得到這:
2012-04-11 16:29:10.419 RandomPossessions[701:403] Object at 0 is zero
2012-04-11 16:29:10.421 RandomPossessions[701:403] Object at 1 is One
2012-04-11 16:29:10.422 RandomPossessions[701:403] Object at 2 is Two
2012-04-11 16:29:10.422 RandomPossessions[701:403] Object at 3 is Three
2012-04-11 16:29:10.423 RandomPossessions[701:403] zero
2012-04-11 16:29:10.423 RandomPossessions[701:403] One
2012-04-11 16:29:10.424 RandomPossessions[701:403] Two
2012-04-11 16:29:10.424 RandomPossessions[701:403] Three
但有時這還不是全部顯示出來。還有一次我運行它,我可以得到:
2012-04-11 16:48:20.626 RandomPossessions[734:403] Object at 0 is zero
2012-04-11 16:48:20.628 RandomPossessions[734:403] Object at 1 is One
我要運行程序幾次去NSLogs的完整列表輸出到控制檯。這是一個錯誤,還是我做錯了什麼? 謝謝
你有沒有添加斷點? (代碼左邊的藍色東西) – 2012-04-11 16:38:09
謝謝。這絕對有幫助。我在return語句中放置了一個斷點。現在我所有的日誌都輸出到控制檯。任何想法爲什麼它沒有這樣做沒有斷點? – Waynelee3d 2012-04-11 17:11:06
對不起,我第一次誤解了你。我以爲你打算讓我把斷點放進去。我一開始在程序中沒有斷點。但是當我添加一個時,我所有的NSLog都得到了輸出。如果沒有斷點,則會丟失一些NSLog輸出。 – Waynelee3d 2012-04-11 17:26:16