Sharing NSMutableArray

Posted by Lucas Veiga on Stack Overflow See other posts from Stack Overflow or by Lucas Veiga
Published on 2011-02-22T14:48:08Z Indexed on 2011/02/22 15:25 UTC
Read the original article Hit count: 188

Filed under:
|

Hey everbody, im trying to share a NSMutableArray to another xib. The cartList.codigo is a NSMutableArray from a shared class, according to James Brannan's tutorial (http://www.vimeo.com/12164589).

When i count it, it gives me 1. But when i load the another view, gives me 0.

Whats wrong?

View that adds:

self.produtoCodigo = [[NSMutableArray alloc]init];
[self.produtoCodigo addObject:@"aa"];

CartViewController *carrinho = [[CartViewController alloc] initWithNibName:@"CartViewController" bundle:[NSBundle mainBundle]];

CartList *lista = [[CartList alloc] init];
carrinho.cartList = lista;
carrinho.cartList.codigo = self.produtoCodigo;

NSLog(@"QTD %i", [carrinho.cartList.codigo count]);

View that wants to load the item added:

- (void) viewDidAppear:(BOOL)animated {

self.produtoCodigo = self.cartList.codigo;

NSLog(@"%i", [self.produtoCodigo count]);


[super viewDidLoad];
}

Im loading the CartList class in both.

Thanks!

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c