Retained Core Foundation Property

后端 未结 2 372
执念已碎
执念已碎 2020-12-29 10:32

(Xcode 4.2, iOS 5, ARC)

I have some properties of Core Foundation (/Graphics) objects that should take ownership of their objects. Now in these Appl

2条回答
  •  别那么骄傲
    2020-12-29 10:39

    Edit: My previous post was incorrect. __attribute__((NSObject)) on the property only causes it to retain/release the property when using the property accessors. It does not affect access to the ivar, and notably, it does not nil out (or release) the property in dealloc. So yes, in your dealloc you either need to say self.loupeImage = nil; or you need to say [_loupeImage release].


    Original post:

    If the compiler accepts the strong keyword, then it's going to treat it correctly, retaining and releasing as expected, and nilling out automatically in ARC. The whole idea of __attribute__((NSObject)) is it tells the compiler to treat this object exactly as if it were an obj-c object, and so that's what it does.

    So no, you shouldn't have to explicitly nil them out in dealloc. You'll get the default ARC behavior of nilling/releasing automatically.

提交回复
热议问题