可能重複:
Declared but unset variable evaluates as true?爲什麼聲明指針使其內容爲零?
爲什麼在Mac OS的代碼工作
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *str;
NSLog(@"%@", [str length]);
NSLog(@"Hello, World!");
[pool drain];
return 0;
}
和控制檯輸出
2011-09-23 15:37:17.481 Untitled1[80021:903] (null)
2011-09-23 15:37:17.495 Untitled1[80021:903] Hello, World!
但在iPhone上崩潰?
日誌中的消息是什麼? –