• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: @synchronized crashing with ARC
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: @synchronized crashing with ARC


  • Subject: Re: @synchronized crashing with ARC
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Thu, 31 May 2012 23:14:51 +0200

Le 31 mai 2012 à 22:28, Lane Roathe a écrit :

>
> On May 31, 2012, at 2:00 PM, Jean-Daniel Dupas <email@hidden> wrote:
>
>> Le 31 mai 2012 à 18:00, Jens Alfke a écrit :
>>
>>> On May 31, 2012, at 8:47 AM, Antonio Nunes wrote:
>>>
>>>> static void *kMyVLFContext = &kMyVLFContext;
>>> ...
>>>> 	@synchronized(kMyVLFContext) {
>>>
>>> Huh? I thought the parameter to @synchronized(…) had to be an object reference?
>>
>>
>> The Objective-C reference agree with you.
>>
>> «The @synchronized() directive takes as its only argument any Objective-C object, including self.»
>>
>> http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjectiveC/Chapters/ocThreading.html#//apple_ref/doc/uid/TP30001163-CH19-SW1
>>
>> I'm surprised the compiler does not complain when passing an arbitrary pointer.
>
> That's because the compiler can't know it's invalid, due to the use of void * as the var type (void * pretty much matches everything, including id, must like id matches any object reference).

> -lane

This is barely an excuse. Trying to send a message to a void * ptr result in the following warning:

receiver type 'void *' is not 'id' or interface pointer, consider casting it to 'id'

So, the compiler is perfectly able to complain when you use a void* instead of an objc object.


-- Jean-Daniel





_______________________________________________

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


  • Prev by Date: EXC_BAD_ACCESS signal in Core Data app on Lion 10.7.4
  • Next by Date: Re: Managed Objects and Contexts
  • Previous by thread: Re: @synchronized crashing with ARC
  • Next by thread: Re: @synchronized crashing with ARC
  • Index(es):
    • Date
    • Thread