• 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: returning from within @synchronized results in warnings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: returning from within @synchronized results in warnings


  • Subject: RE: returning from within @synchronized results in warnings
  • From: "Karan, Cem (Civ, ARL/CISD)" <email@hidden>
  • Date: Wed, 12 Aug 2009 10:36:12 -0400
  • Thread-topic: returning from within @synchronized results in warnings

Paul Summermatter wrote on Wednesday, August 12, 2009 8:27 AM

> Cem,
>
> 	I'm a reborn Objective-C'er, but so take my advice as
> probably not the most experienced since synchronized was not
> even available the last time I used Objective-C.  That being
> said, I would have expected to see something more like:
>
> - (NSString *)name
> {
> 	NSString *retval;
>
> 	@synchronized (self) {
> 		retval = [[name retain] autorelease];
> 	}
>
> 	return retval;
> }

Yeah, that is what I thought as well, but I was told that this is not
the case; apparently, the compiler is smart enough to insert the code to
unlock in all the right places.  See the last couple of paragraphs at
http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/ObjectiveC/Art
icles/ocThreading.html and look around on the Objective-C mailing list.

> 	Also, I thought if you used properties that all of this
> was done properly for you under the covers.  Unless you have
> a specific need to define your own accessor, you might
> consider just using a property.

I simplified the code example because my actual properties definitions
are more complex; I use @dynamic and define my own properties to handle
the extra stuff that needs to be handled.  So, while I would LIKE to use
pure properties, in my case, it just doesn't make sense.

Thanks,
Cem Karan
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >returning from within @synchronized results in warnings (From: "Karan, Cem (Civ, ARL/CISD)" <email@hidden>)
 >Re: returning from within @synchronized results in warnings (From: Paul Summermatter <email@hidden>)

  • Prev by Date: Re: returning from within @synchronized results in warnings
  • Next by Date: RE: returning from within @synchronized results in warnings
  • Previous by thread: Re: returning from within @synchronized results in warnings
  • Next by thread: Build Error Concerning Frameworks
  • Index(es):
    • Date
    • Thread