Alternative to Objective-C objects in structs (ARC

2019-02-25 11:39发布

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条回答
爷的心禁止访问
2楼-- · 2019-02-25 12:35

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)

查看更多
登录 后发表回答