>From Clark S. Cox III.  This answers a question that has kindof been in my 
mind for a while and I felt it was useful enough to post back to the list.

PS: be as blunt as you like :)

----------------------

objc_msgSend and friends are special. They expect to be called *as if*
they were defined with the same parameters and return type as the
method being called. In the case of BOOL, it is unlikely that id and
BOOL would be returned in different ways, butnits best to always do
the right thing whenever possible.

Sent from my iPhone

On Mar 6, 2009, at 12:22, "Paul Sanders" wrote:

>> To put it bluntly, Nick's solution is the correct way to do this.
>> Just
>> casting the return value may work for now, but there are no
>> guarantees.
>
> Why not?  It seems to me that the two approaches are equivalent.  Both
> assume that objc_msgSend will return something that can be cast to a
> BOOL.
> The difference is purely one of style.
>
> Nick's solution has the advantage that one does not need to assume
> that
> sizeof (long) == sizeof (id) in both 32 and 64 bit mode.  Our
> messages - his
> and mine - crossed in the post.
>
> PS: You could cast via an NSInteger, which I believe is meant to
> represent
> the native word length of the machine, but that is only defined in
> the 10.5
> SDK and later.

_______________________________________________

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

Reply via email to