'assign'和'weak'是互斥的

时间:2012-04-12 11:03:47

标签: objective-c ios4 twitter

我正在尝试TwitPic使用GSTwitPicEngine类在Twitter上发布带有文本的图像,该类使用YAJLiOS,

所以我在我的项目中添加了YAJLiOS框架,我在YAJLiOS框架中的文件“YAJLParser.h”中得到了这个('assign'和'weak'是互斥的)错误。 在以下行中显示错误 -

@property (assign, nonatomic) __weak id <YAJLParserDelegate> delegate;

当我删除__weak时,它变为Apple Mach-O Linker(Id)错误。

请帮忙。如何处理这种错误。我没有理由。

3 个答案:

答案 0 :(得分:1)

傻傻的我......

@property (unsafe_unretained, nonatomic) id <YAJLParserDelegate> delegate;

答案 1 :(得分:1)

可能你现在想通了, 无论如何这里是我如何摆脱这个错误:

@property (assign) __unsafe_unretained id<YAJLParserDelegate> delegate;   

确保.h代码中的delegate的所有其他声明(如果有)都是__unsafe_unretained,例如在@private部分:

__unsafe_unretained id<YAJLParserDelegate> delegate;

答案 2 :(得分:0)

正如你可能已经知道的那样,分配并不是一回事......功能上它们非常接近,但弱点更复杂而且相当巧妙将对已处置对象的引用置零以避免崩溃(除其他外,保留周期)。

无论如何 - 该怎么办?我最好的猜测是尝试取消ARC的向后兼容性旧版修复...用 _ > _unsafe_unretained ,看看情况如何。