【发布时间】:2013-10-20 15:32:40
【问题描述】:
您好,我有一个实例变量 NSMutable Array。
我这样声明
@property (nonatomic, assign) NSMutableArray *list;
在 viewDidLoad 我实例化它。
self.list = [NSMutableArray array];
然后我创建一个包含文本字段文本的字符串并将其添加到数组中。
NSString * lines = [NSString stringWithFormat:@"%@,%@,%@,%@,%@", [self.crabText text], [self.trawlText text], [self.trapText text], [self.vesselText text], [self.lengthText text]];
[self.list addObject:lines];
这是一个函数的一部分,它将继续将文本字段的新值添加到数组中。
我用
显示数组的内容int i;
int count;
for (i = 0, count = [self.list count]; i < count; i = i + 1)
{
NSString *element = [self.list objectAtIndex:i];
NSLog(@"The element at index %d in the array is: %@", i, element); // just replace the %@ by %d
}
但是,当我尝试打印数组的内容时,应用程序崩溃了
EXC_BAD_ACCESS_CODE
有什么想法吗?
谢谢!
【问题讨论】:
标签: ios xcode nsstring nsmutablearray