你能帮我理解一个错误吗?我的项目是一个modalController,它出现并让用户将新文本保存在mutableArray 中。
我从调试器收到此错误:
2011-07-21 16:53:52.362 aeffa[18089:207] -[__NSArrayI addObject:]: 无法识别的选择器发送到实例 0x4b042d0
我检查了代码,但看不出有什么问题:“取消”按钮工作正常,但“保存”按钮启动错误。这是我的代码:
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self
action:@selector(cancel:)] autorelease];
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemSave
target:self
action:@selector(save:)] autorelease];
}
和方法:
- (IBAction)cancel:(id)sender {
[self dismissModalViewControllerAnimated:YES];
}
- (IBAction) save:(id)sender{
Website *newSite = [[Website alloc]init];
NSURL *newURL = [[NSURL alloc ]initWithString:url.text];
newSite.websiteURL = newURL;
newSite.websiteTitle = titre.text;
newSite.websiteDesc = descr.text;
[tabWebSites addObject:newSite];
[newURL release];
[newSite release];
}
谢谢
保罗