could you help me to understand an error? my project is a modalController that appears and let the user save a new text in a mutableArray.
I receive this error from the debugger :
2011-07-21 16:53:52.362 aeffa[18089:207] -[__NSArrayI addObject:]: unrecognized selector sent to instance 0x4b042d0
I checked the code but i can’t see what’s wrong : the “cancel” button works fine, but the “save” button launches the error. Here’s my code :
- (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];
}
and the methods :
- (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];
}
Thanks
Paul
I believe your
tabWebSitesis actually anNSArrayobject.. which doesn’t have aaddObject:method. Make sure it’sNSMutableArray(you probably allocate it as aNSArray, even if it might be declared asNSMutableArray).