ios - 如何找到对象正在释放的位置

标签 ios memory-management xcode7

我只在 iOS8 中遇到这个错误,在 iOS9 中工作正常

[DetailView respondsToSelector:]: message sent to deallocated instance 0x7c818a20

有什么方法可以找到我的对象在哪里取消分配?

我知道 xcode 中有工具 zoombie,但它只提供上述信息,我也尝试过分析但没有任何帮助。

我也放置了异常断点,但控制并没有在代码中的任何地方中断。

见附图 enter image description here

在 My MainVC.m 中设置一个属性 @property (nonatomic,strong) DetailView *d;

单击 MainVC.m 中的按钮(我必须将此详细 View 添加为 subview )

_d = [[DetailView alloc]initWithData:dict andImgId:[[_arrayHotelimg objectAtIndex:0] valueForKey:@"img_id"] isTour:NO];
_d.dictData = [_dbObj getHotelDescriptionDataFromHid:_iTabId];
_d.delegate = self;
[self.view addSubview:_d];

细节 View .m

-(id)initWithData:(NSDictionary*)dict andImgId:(NSString*)imgId isTour:(BOOL)isTour{
    self = [super initWithFrame:CGRectMake(0, TOP, SCREEN_WIDTH, SCREEN_HEIGHT)];
    if (self)
    {
    self.arrGalleryImages = [NSMutableArray new];
    _dbObj = [Database Connetion];

    NSArray *subviewArray = [[NSBundle mainBundle] loadNibNamed:@"DetailView" owner:self options:nil];
    self = [subviewArray objectAtIndex:0];
    self.frame = CGRectMake(0, TOP, SCREEN_WIDTH, SCREEN_HEIGHT);
    }
    return self;
}

任何人都可以帮助我如何找到破坏的代码或在哪里释放对象?

为什么它适用于 iOS9 而不适用于 iOS8?

最佳答案

在您的类实现中添加方法 -dealloc() 并在其中放置断点。然后你就会知道你的对象何时被释放。

关于ios - 如何找到对象正在释放的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39120895/

相关文章:

c - 调用 free 后内存使用量不会减少

swift - ios沙盒恢复非消耗性IAP无需购买

ios - 在 Xcode 7 中固定两个 UIImage View 之间的水平间距

ios - 无法将自定义类分配给 Xcode 7 中的 View

ios - 有没有办法强制更改您的 iOS 推送通知 deviceToken?

ios - 将按钮列表与自动布局水平对齐

ios - Objective-C 中的单元测试私有(private)类

c - 为什么我能够复制比 char 数组中定义的字节更多的字节?

ios - 使用 dispatch_async 时的 EXC_BAD_ACCESS

cocoa - 我需要保留 NSAlert AlertDidEnd 的 contextInfo 吗?