NSMutableArray问题

Buy*_*ian 2 iphone cocoa-touch objective-c

谁能解释为什么这段代码破坏了我的应用:

NSMutableArray *myArray = [[NSMutableArray alloc] initWithObjects:@"recipeA", @"recipeA1", @"recipeA2", @"recipeA3",@"recipeA4",@"recipeA5",@"recipeA6",@"recipeA7",nil];

//these both break the app with invalid pointer type warnings
NSLog("What is 0: %@", [myArray objectAtIndex:0]);
NSLog("What is the count: %i", [myArray count]);
Run Code Online (Sandbox Code Playgroud)

小智 11

你忘记了@NSLog字符串的前面:

NSLog(@"What is 0: %@", [myArray objectAtIndex:0]);
NSLog(@"What is the count: %i", [myArray count]);
Run Code Online (Sandbox Code Playgroud)