On Sun, Nov 8, 2009 at 12:11 PM, Stuart Malin <stu...@zhameesha.com> wrote: > 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%3Alists.apple.com+%40synchronized+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).
The warning is a bug, and can be safely ignored. The compiler isn't able to do the proper flow analysis to see that all ways out of the function return a valid value. If you don't like ignoring warnings, you can adjust your code to work around it: - (id) someMethod { id result = nil; @synchronized(self) { result = [somevalue autoreleae]; } return result; } > 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. That is not true. @synchronized (as well as @try/@catch/@finally) behave properly in the presence of returns. The problem here is in the compiler's diagnostics, not in the code generated -- Clark S. Cox III clarkc...@gmail.com _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com