Alternative to Objective-C objects in structs (ARC)

。_饼干妹妹 提交于 2019-12-04 04:24:33

问题


I have the following code here that won't run on ARC since it combines Objective-C objects in structs:

struct SingleToManyRelation {
    id singleObject;
    NSSet* manyObjects;
}

I know this is reminiscent of Core Data, but that's not the point ;) I am just looking for a solution to implement something like that without having to create a "container" class.

Thanks in advance for your advices, Christian


回答1:


Give your objects the __unsafe_unretained attribute and ARC will stop complaining (but keep in mind that they aren't retained! So you have to somehow store a strong relationship to them, if you don't want to lose them)



来源:https://stackoverflow.com/questions/10055404/alternative-to-objective-c-objects-in-structs-arc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!