Re: How to implement readonly property
Re: How to implement readonly property
- Subject: Re: How to implement readonly property
- From: Joerg Simon <email@hidden>
- Date: Mon, 12 Nov 2012 15:41:46 +0100
As you can read in the blog too, the developer documentation of dispatch_once states:
"The predicate must point to a variable stored in global or static scope. The result of using a predicate with automatic or dynamic storage is undefined."
so, no, you can not. Actually it works most of the time, but you can not rely on it...
Cheers, Jörg
On Nov 12, 2012, at 3:33 PM, Tom Davie <email@hidden> wrote:
>
> On 12 Nov 2012, at 14:18, Joerg Simon <email@hidden> wrote:
>
>> You can use dispatch_sync. The blog post of oliver dobnigg (cocoanetics) summs that up quite nicely:
>> http://www.cocoanetics.com/2012/02/threadsafe-lazy-property-initialization/
>
> Or you can use dispatch_once, but make sure the once token is an ivar, unlike I did.
>
> Tom Davie
_______________________________________________
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