Re: CGImageRef as a property of a cocoa object
Re: CGImageRef as a property of a cocoa object
- Subject: Re: CGImageRef as a property of a cocoa object
- From: Dave <email@hidden>
- Date: Sat, 21 Sep 2013 16:13:42 +0100
On 15 Sep 2013, at 12:24, Roland King <email@hidden> wrote:
>
> The clang document which bbum links to says it has to be a typedef. So that gives you two good reasons, one that the documentation mandates a typedef and the other that Bill Bumgarner weighed in. So I'd say, if you want to try this, you have to use a typedef.
>
> The clang document also really recommends against using the typedef. Whereas the pointer will be treated correctly by ARC, it suggests other operations on it might not work, gives two examples, the inference I drew reading it was 'these two or other things we haven't really thought about'.
>
> I don't know as there is a recommended way to do what you like. In the past when I have a CoreFoundation object I want as a property, I don't specify anything in the property definition apart from readwrite and I write my own getter and setter to CFRetain()/CFRelease() it (and remember to do something appropriate to release it in dealloc). Always worked fine for me at the expense of a few lines of code.
>
Yes, that's what I do too, except use a property, then you just set it to nil.
Also CF objects will throw an exception if you call release with a nil pointer, so you can check for this in your setter.
All the Best
Dave
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden