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];
}
由于
保
答案 0 :(得分:1)
我相信您的tabWebSites
实际上是一个NSArray
对象..它没有addObject:
方法。确保它是NSMutableArray
(您可能将其分配为NSArray
,即使它可能被声明为NSMutableArray
。)