how to use delegates with Automatic Reference Counting

前端 未结 1 1162
旧时难觅i
旧时难觅i 2020-12-24 05:00

I\'ve jumped on the ARC bandwagon. In the past I would have my delegate properties declared like this:

@property(assign) id delegate;


        
相关标签:
1条回答
  • 2020-12-24 05:44

    "ivar" means "instance variable", which you have not shown. I'm betting it looks something like this:

    @interface Foo : NSObject {
        id delegate;
    }
    
    @property (weak) id delegate;
    

    What the error is saying is that it must look like this:

    @interface Foo : NSObject {
        __weak id delegate;
    }
    
    @property (weak) id delegate;
    

    If the property claims to be weak, the ivar that the value ends up being stored in must be weak as well.

    0 讨论(0)
提交回复
热议问题