xcode ARC转换错误[CFString保留]崩溃 [英] xcode ARC conversion error [CFString retain] crash

查看:64
本文介绍了xcode ARC转换错误[CFString保留]崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用xcode自动转换将庞大的IOS程序转换为ARC.之后,我得到以下错误: [CFString keep]:发送到已释放实例的消息

I converted my huge IOS program to ARC using xcode auto conversion. After that I am getting the following error: [CFString retain]: message sent to deallocated instance

跟踪显示崩溃的行如下:

The trace shows the following line where it crashed:

UIImage *image = [[UIImage alloc] initWithContentsOfFile:tile.imagePath];

跟踪的下一行给出:/SourceCache/arclite/arclite-7.1/source/arclite.m:241

Next line in the trace gives:__arclite_objc_retainAutoreleasedReturnValue at /SourceCache/arclite/arclite-7.1/source/arclite.m:241

有人可以建议我可以进一步看的地方吗,或者该怎么做才能消除此崩溃?

Can someone suggest me where I can look further, or what can I do to remove this crash?

非常感谢

看起来下面的代码中的(NSString *)p初始化需要一些更改.我应该如何更改它,以免tile.imagePath变为null?

Looks like the (NSString *)p initialization in the code below needs some changes. How should I change it, so that the tile.imagePath doesn't become null?

- (id)initWithFrame:(MKMapRect)f path:(NSString *)p{
    if (self = [super init]) {
        imagePath = p;
        frame = f;
    }
    return self;
}

谢谢.

推荐答案

imagePath可能是__unsafe_unretained iVar(或者您看到的是weakassign).将其更改为strong,以便由ARC保留.

imagePath is probably a __unsafe_unretained iVar (or maybe you're seeing weak or assign). Change it to strong so that it is retained by ARC.

这篇关于xcode ARC转换错误[CFString保留]崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆