0
我试图传递给另一个xib NSMutableArray的一些数据。我创建了一个名为Gallery的NSObject类。我在两个视图加载它。丢失xib之间的数据
Im加载一个填充NSMutableArray的XML。然后,当我进入的第一个视图,它填补了NSMutableArray的完美,给我的是一个NSLog的内容:
ProductPhotoGallery *telaGaleria = [[ProductPhotoGallery alloc] initWithNibName:@"ProductPhotoGallery" bundle:[NSBundle mainBundle]];
Gallery *minhaGaleria = [[Gallery alloc] init];
telaGaleria.galeria = minhaGaleria;
telaGaleria.galeria.galeriaFotos =[[NSMutableArray alloc]init];
TBXMLElement * nodeFotos = [TBXML childElementNamed:@"fotos" parentElement:rootXMLElement];
TBXMLElement * nodeFoto = [TBXML childElementNamed:@"foto" parentElement:nodeFotos];
while (nodeFoto) {
NSString * urlFoto = [TBXML textForElement:nodeFoto];
[telaGaleria.galeria.galeriaFotos addObject:urlFoto];
NSLog(@"%@", urlFoto);
nodeFoto = [TBXML nextSiblingNamed:@"foto" searchFromElement:nodeFoto
];
}
[telaGaleria release];
NSLog(@"Array da Galeria %@", telaGaleria.galeria.galeriaFotos);
正确地给予我说,我加载其他视图:
-(IBAction) vaiGaleria{
ProductPhotoGallery *telaDaGaleria = [[ProductPhotoGallery alloc] initWithNibName:@"ProductPhotoGallery" bundle:[NSBundle mainBundle]];
// Puxando a view
[self.navigationController pushViewController:telaDaGaleria animated:YES];
[telaDaGaleria release];
}
所以,当另一种观点来临时,我设置为显示在日志中的数组:
- (void)viewDidLoad {
self.galeria.galeriaFotos =[[NSMutableArray alloc]init];
NSLog(@"ARRAY GALERIA DENTRO VIEW %@", self.galeria.galeriaFotos);
[super viewDidLoad];
}
,这让我空值。那么发生了什么?
谢谢!
没有人可以帮助我吗? – 2011-01-12 15:38:17