Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSMutableArray not adding object! (using addObject: nor addObjectsFromArray)

(IBAction)adicionarPastas:(id)sender {

    AbreBrowser *abre = [[AbreBrowser alloc] init];

    NSMutableArray *arquivosRecebe = [[NSMutableArray alloc] initWithArray:[abre abreBrowser]];
    [abre release];

    [arquivos addObjectsFromArray:arquivosRecebe];    
    [arquivosTableView reloadData];

    [arquivosTableView setDataSource:self];
}

Well, arquivos is declared on this files header as:

NSMutableArray *arquivos;

[abre abreBrowser] indeed returns a NSArray.

My problem is [arquivos addObjectsFromArray:arquivosRecebe]; doesn't work. I also tried addObject and it gives me the same result, i.e. nothing.

When I feed arquivos like this:

arquivos = [abre abreBrowser]; 

it works. But when I do a [arquivos addObject:Object] or [arquivos addObjectsFromArray:NSArray] it doesnt feeds my NSMutableArray arquivos.

Can someone tell me what I'm doing wrong?

like image 967
Crofuncio Avatar asked May 15 '11 20:05

Crofuncio


1 Answers

It appears that you are not allocating arquivos anywhere in your object's initialization before actually sending the addObjectsFromArray message to it.

like image 108
sinha Avatar answered Oct 31 '22 02:10

sinha