objective c - "unrecognized selector" on "Save" button? -
could me understand error? project modalcontroller appears , let user save new text in mutablearray.
receive error debugger :
2011-07-21 16:53:52.362 aeffa[18089:207] -[__nsarrayi addobject:]: unrecognized selector sent instance 0x4b042d0
i checked code can't see what's wrong : "cancel" button works fine, "save" button launches error. here's 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 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 tabwebsites
nsarray
object.. doesn't have addobject:
method. make sure it's nsmutablearray
(you allocate nsarray
, if might declared nsmutablearray
).
Comments
Post a Comment