2010-11-23 25 views
1

Toute aide que vous pouvez offrir serait appréciée.NSIndexPath: message envoyé à l'instance désaffectée

J'ai une application qui a une tableView, detailView, flipView, et plusDetail View. C'est bien de passer à travers les transitions jusqu'au 26ème élément. L'application se bloque lorsque je clique sur les boutons qui naviguent vers le flip et plusDetailView.

Je reçois l'erreur Msg: [NSIndexPath row] message sent to deallocated instance.

Je pense que j'appelle l'indexPath trop de fois, mais pourquoi tout fonctionne bien jusqu'au 25ème élément et puis arrête de fonctionner? Comment le NSIndexPath a-t-il été désalloué? Je ne l'ai jamais libéré.

Si vous le savez, aidez s'il vous plaît. Je vous remercie!!!

Xcode dit que le problème est ici:

@implementation produceView aka *detailView* 

- (IBAction)showInfo { 

     FlippedProduceView *fView = [[FlippedProduceView alloc]initWithIndexPath:index]; 
    fView.flipDelegate = self; 


    fView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 
    [self presentModalViewController:fView animated:YES]; 
     [fView release]; 

} 


- (IBAction) buttonPushed:(id)sender 

{ 

    picView *pictureView = [[picView alloc]initWithIndexPath:index]; 


    pictureView.picDelegate = self; 
    pictureView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;  

    [self presentModalViewController:pictureView animated:YES]; 
     [pictureView release]; 
} 

-(id)initWithIndexPath:(NSIndexPath *)myIndexPath { 
if (self == [super init]) { 
      path = myIndexPath; 

    } 
    return self; 

} 

@implementation picView aka *moreDetailView* 

- (void)viewDidLoad { 
    RipeGuideAppDelegate *AppDelegate = (RipeGuideAppDelegate *)[[UIApplication sharedApplication] delegate]; 
    self.picViewArray = AppDelegate.arrayProduceInfo; 

    NSMutableDictionary *dictionary = [picViewArray objectAtIndex:path.row]; 
} 

@implementation FlippedProduceView aka *flipView* 


- (id)initWithIndexPath:(NSIndexPath *)myIndexPath { 
    if (self == [super init]) { 
     indexes = myIndexPath; 
    } 
    return self; 
} 

- (void)viewDidLoad { 
    RipeGuideAppDelegate *AppDelegate = (RipeGuideAppDelegate *)[[UIApplication sharedApplication] delegate]; 
    self.flipViewArray = AppDelegate.arrayProduceInfo; 

    NSMutableDictionary *dictionary = [flipViewArray objectAtIndex:indexes.row]; 
} 
+0

Pouvez-vous s'il vous plaît mettre le code dans des blocs de code (Ctrl-K)? C'est * très * difficile à lire – Fred

+0

Merci Alex! : D – Fred

Répondre

12

Vous devez utiliser les propriétés (@property (retain) NSIndexPath *path;) au lieu de variables d'instance, donc alors quand vous faites self.path = myIndexPath il augmente le il comptera conserver afin de ne pas être désallouée quand IndexPath est auto-libéré.

+0

J'ai essayé Fred, mais ça n'a pas marché. Merci quand même. J'apprécie votre aide. –

+0

Oups, je l'ai encore essayé et tu avais raison. Merci beaucoup!!! Vous êtes un épargnant de vie ou un épargnant de cheveux. –

+0

Content de vous aider. : D – Fred