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