【发布时间】:2011-08-18 14:51:30
【问题描述】:
使用此代码,我收到此错误:
'* -[NSMutableArray insertObject:atIndex:]: 尝试插入 nil 0' 处的对象
categories=[[NSMutableArray alloc] init ];
UIAlertView* dialog = [[UIAlertView alloc] init];
[dialog setDelegate:self];
[dialog setTitle:@"Category name"];
[dialog setMessage:@" "];
[dialog addButtonWithTitle:@"Cancel"];
[dialog addButtonWithTitle:@"OK"];
nameField = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 45.0, 245.0, 25.0)];
[nameField setBackgroundColor:[UIColor whiteColor]];
[dialog addSubview:nameField];
[dialog show];
[dialog release];
[categories addObject:[nameField text]];
[nameField release];
[categoryTable reloadData];
当我在模拟器中运行它时,我什至在警报视图弹出之前就崩溃了。有什么想法吗?
【问题讨论】:
标签: iphone objective-c ios cocoa-touch uialertview