On Sun, Jul 6, 2008 at 12:05 PM, Jean-Daniel Dupas
<[EMAIL PROTECTED]> wrote:
>
> Le 6 juil. 08 à 17:35, Michael Ash a écrit :
>
>> Do you want to keep a reference to a CF object? If yes, use __strong.
>> End of story.
>>
>> You might use __weak if you want a zeroing weak reference. But this is
>> extremely uncommon in a dual-mode framework such as what you're
>> writing, because there's no equivalent to __weak in the non-GC world.
>>
>> Aside from wanting a zeroing weak reference, there's no real reason
>> not to use __strong. The only reason would be for performance, and as
>> we all know, premature optimization is the root of all evil.
>>
>> You *can* leave off the __strong keyword, provided you do your
>> CFRetains and CFReleases properly and implement a -finalize method to
>> clean things up. But this is less efficient, requires more brainpower,
>> and is unnecessary.
>
> I think the rule may be:
> use __strong for retained/copied ivars, and nothing for assigned ivars.

If the ivar is an ObjC object, then it's already strong automatically,
unless you explicitly specify __weak. If it's a CF reference, then you
really ought to use either __strong or __weak. If you use nothing,
then you're just setting yourself up to explode if the object is
collected. Sure, you can get your retains and releases set up to avoid
that, but why bother when you have the collector there? The only
reason to not put __strong on a CF ref that you would otherwise be
leaving blank would be for speed, and that consideration should always
come much later.

Mike
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to