NSIndexPath:发送到解除分配的实例的消息 [英] NSIndexPath: message sent to deallocated instance
问题描述
您可以提供的任何帮助将不胜感激。
Any help you can offer would be appreciated.
我有一个包含tableView,detailView,flipView和moreDetail View的应用程序。它很好地通过过渡直到第26个元素。当我点击导航到flip和moreDetailView的按钮时,应用程序崩溃了。
I have a app that has a tableView, detailView, flipView, and moreDetail View. It is fine moving through the transitions until the 26th element. The app crashes when I hit buttons that navigate to the flip and moreDetailView.
我收到错误消息: [NSIndexPath row]消息发送到解除分配的实例
。
I am given the error Msg: [NSIndexPath row] message sent to deallocated instance
.
我想我可能会多次调用indexPath,但为什么一切都运行良好直到第25个元素然后停止工作? NSIndexPath是如何解除分配的?我从来没有解除分配。
I think I may be calling the indexPath too many times, but why does everything work well up until the 25th element and then stop working? How did the NSIndexPath get deallocated? I never deallocated it.
如果您知道,请帮忙。谢谢!!!
If you know, please help. Thank you!!!
Xcode表示问题在于:
Xcode says the problem is here:
@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];
}
推荐答案
你应该使用属性( @property(retain)NSIndexPath * path;
)而不是实例变量,所以当你执行 self.path = myIndexPath
然后它会提高保留计数,以便在自动释放IndexPath时不会释放它。
You should use properties (@property (retain) NSIndexPath *path;
) instead of instance variables, so then when you do self.path = myIndexPath
then it raises the retain count so it won't be deallocated when IndexPath is autoreleased.
这篇关于NSIndexPath:发送到解除分配的实例的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!