Re: Compile error using @synchronized on methods that return values
Re: Compile error using @synchronized on methods that return values
- Subject: Re: Compile error using @synchronized on methods that return values
- From: Stuart Malin <email@hidden>
- Date: Sun, 8 Nov 2009 15:11:56 -0500
On Nov 8, 2009, at 2:56 PM, Adam R. Maxwel wrote:
On Nov 8, 2009, at 3:03 AM, Ken Tozier wrote:
"Control reaches end of non-void function"
I Googled for "Objective-C accessors and @synchrinized" which
seemed to indicate that the following was the correct way to handle
it
- (id) someMethod
{
@synchronized(self)
{
return [somevalue autoreleae];
}
}
But I get the above error whenever I try to do it that way. Here's
one of the actual methods with and without the @synchronized
directive
http://lists.apple.com/archives/Xcode-users/2009/Aug/msg00230.html
More info can be found using google:
http://www.google.com/search?hl=en&q=site:lists.apple.com+@synchronized+Control+reaches+end+of+non-void+function&aq=f&oq=&aqi=
Whether this warning is a bug (as suggested by the 00230 post
referenced above) or not, I don't know (I'm way at the extreme end of
my programmer's union card on this one). But I suspect that from the
posters comments in the post I reference below, it isn't a bug. The
problem is, you can't return up the calling chain while being
synchronized. Do whatever work it is that needs to be performed in a
synchronized way, then return whatever result needs to be returned.
Here's the post I found (using the Google search supplied by Adam):
http://lists.apple.com/archives/Xcode-users/2006/Sep/msg00111.html
_______________________________________________
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