On Jun 8, 2010, at 10:16 AM, James Bucanek wrote: > I've been trying to track down a peculiar bug reported by a customer, and > I've narrowed it down to a problem returning a BOOL value via -[NSObject > performSelector:] on a dual Quad-Core Intel Xeon processor running 64-bit > code. It seems that the returned value contains random data, which obscures > the BOOL. > > I've included the relevant code from the project below for completeness, but > the problem boils down to this statement: > > if ([condition performSelector:conditionSelector]!=NO)
According to the documentation, that method returns an object, not a primitive. You can't use it if the selector returns a primitive; it doesn't work that way. If you want to call some selector and get a BOOL return value, then you must do this instead: BOOL returnValue = ((BOOL (*)(id, SEL))objc_msgSend)(condition, conditionSelector); This, incidentally, works for all primitives except for some floating point primitives, where you may have to use objc_msgSend_fpret() instead depending on the rules of your architecture. > I thought that, in Objective-C, all pointer and integer scalar values were > interchangeable in the return value of a method. You thought wrong. Nick Zitzmann <http://www.chronosnet.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