iphone - NSMutableArray 问题

标签 iphone objective-c cocoa-touch

谁能解释一下为什么这段代码会破坏我的应用程序:

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]);

最佳答案

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

NSLog(@"What is 0: %@", [myArray objectAtIndex:0]);
NSLog(@"What is the count: %i", [myArray count]);

关于iphone - NSMutableArray 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4995654/

相关文章:

ios - 未设置 AppIcon

iphone - 显示加载

iPhone Interface Builder - 将资源移至子目录,现在 IB 看不到它们!

objective-c - 将文件保存在 OS X 中的私有(private)文件夹中,例如 iOS 文档文件夹

objective-c - 无法追加到 NSString

objective-c - iOS 转场太慢

ios - 如何更新现有的.plist?

ios - Xcode10运行模拟器警告启动失败

iphone - 为什么 iOS NSDefaults 需要启动两次才能生效?

ios - 将 View Controller 推送到选项卡 Controller 中的 View 控件