0
votes

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

1
How do you initialize tabWebSites ? - albertamg

1 Answers

1
votes

I believe your tabWebSites is actually an NSArray object.. which doesn't have a addObject: method. Make sure it's NSMutableArray (you probably allocate it as a NSArray, even if it might be declared as NSMutableArray).