2010-11-23 70 views
1

任何幫助,您可以提供的消息,將不勝感激。NSIndexPath:發送到釋放實例

我有具有的tableView,的DetailView,flipView和瀏覽更詳細查看一個應用程序。直到第26個元素轉換過程都很好。當我點擊導航到flip和moreDetailView的按鈕時,該應用程序崩潰。

我給出的錯誤信息:[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 2010-11-23 04:13:03

+0

謝謝亞歷克斯! :D – Fred 2010-11-23 06:42:27

回答

12

您應該使用性質(@property (retain) NSIndexPath *path;),而不是實例變量,所以後來當你self.path = myIndexPath那麼它提出了保留計數,所以它不會被釋放時, IndexPath是自動發佈的。

相關問題