2010-11-23 8 views
1

提供できるヘルプがあれば幸いです。NSIndexPath:割り当て解除されたインスタンスにメッセージが送信されました

私は、tableView、detailView、flipView、およびmoreDetailビューを持つアプリを持っています。遷移を通して26番目の要素まで動くのはうまいです。私はフリップとmoreDetailViewに移動するボタンを押すと、アプリケーションがクラッシュします。

エラーメッセージMsg:[NSIndexPath row] message sent to deallocated instanceが表示されます。

私はindexPathを何回も呼び出すかもしれないと思いますが、すべてが25番目の要素までうまくいってから作業を停止するのはなぜですか? NSIndexPathはどのようにして解放されましたか?私は決してそれを割り当て解除しなかった。

ご存知の場合は、お手数ですが、ありがとうございました!!!

Xcodeのは問題がここにあると言う:

@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

コードをコードブロック(Ctrl-K)に置いてください。読むのがとても難しい* – Fred

+0

ありがとうアレックス! :D – Fred

答えて

12

あなたはself.path = myIndexPathを行うときに、それはときに割り当て解除されないようにそうそしてそれは保持カウントを発生させ、代わりにインスタンス変数のプロパティ(@property (retain) NSIndexPath *path;)を使用する必要がありますIndexPathは自動リリースされます。

+0

私はフレッドを試しましたが、うまくいきませんでした。ありがとう、結構です。私はあなたの援助に感謝します。 –

+0

おっと、私はもう一度試してみると、あなたは正しいです。どうもありがとうございます!!!あなたは救命救助者か髪の毛の保護者です。 –

+0

喜んで助けてください。 :D – Fred