1

您可以提供的任何帮助将不胜感激。

我有一个应用程序,它有一个 tableView、detailView、flipView 和 moreDetail View。在过渡到第 26 个元素之前移动很好。当我点击导航到翻转和 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];
}
4

1 回答 1

12

您应该使用属性 ( @property (retain) NSIndexPath *path;) 而不是实例变量,因此当您这样做时,self.path = myIndexPath它会提高保留计数,因此在自动释放 IndexPath 时不会释放它。

于 2010-11-23T04:22:29.987 回答