2011-01-12 19 views
0

Imは別のxibにNSMutableArrayのデータを渡そうとしています。私はGalleryというNSObjectクラスを作成しました。両方のビューに読み込んでいます。xib間のデータの損失

私はNSMutableArrayを塗りつぶすXMLを読み込みます。私は最初のビューを入力するときに、それは完全にNSMutableArrayのを満たし、そして私のNSLog上のそれの内容与える:

-(IBAction) vaiGaleria{ 

    ProductPhotoGallery *telaDaGaleria = [[ProductPhotoGallery alloc] initWithNibName:@"ProductPhotoGallery" bundle:[NSBundle mainBundle]]; 

    // Puxando a view 

    [self.navigationController pushViewController:telaDaGaleria animated:YES]; 

    [telaDaGaleria release]; 


} 
:正しくは私のことを与えて

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); 

を、私は他のビューをロード

別のビューが来たときに、私は、ログ上のアレイを表示するように設定します。

- (void)viewDidLoad { 

    self.galeria.galeriaFotos =[[NSMutableArray alloc]init]; 

    NSLog(@"ARRAY GALERIA DENTRO VIEW %@", self.galeria.galeriaFotos); 

    [super viewDidLoad]; 
} 

そして、それは私にnull値を与えます。それでは、何が起こっているのですか?

ありがとうございます!

+0

誰も助けてくれませんか? –

答えて

1

viewDidLoadの最初の行を削除して、以前割り当てた配列を解放し、新しい配列を割り当てます。

+0

どうすればいいですか? –

関連する問題