Re: NSImage from bitmap - then delete bitmap
Re: NSImage from bitmap - then delete bitmap
- Subject: Re: NSImage from bitmap - then delete bitmap
- From: Roland King <email@hidden>
- Date: Wed, 27 Jul 2016 10:32:45 +0800
> On 27 Jul 2016, at 10:05, Trygve Inda <email@hidden> wrote:
>
>>
>
> How is it retained by the main thread without an explicit retain call?
are you not using ARC? If you are then all such references, both variable and during method calls are retained automatically. If you’re not, then do what ARC does and retain it explicitly and release it explicitly (and start using ARC in that case!)
>
> I would be no different than a main thread calling:
>
> someVar [[MyObj alloc] init]
> [someVar doSomething];
That isn’t compilable code. Did you mean
someVar = [ [ MyObj alloc]init ]
[ someVar doSomething ];
>
> If a worker thread were able to call [someVar release] between these two
> lines, the doSomething call could fail.
>
Again if you’re using ARC, none of these issues are issues.
Why would a worker thread call [ someVar release ] on a variable it didn’t retain in the first place? If that’s actually a realistic scenario and you’re not using ARC, then call retain on someVar when you assign it in the first place and release it only after you’re finished with it, after the call to doSomething. Which, by the way, is pretty much what ARC does.
>
>
_______________________________________________
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