Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page > Hide TOC

Objective-C Runtime: Sending Messages

The information in this section is only for developers who use the Objective-C runtime library, which is used primarily for developing bridge layers between Objective-C and other languages, or for low-level debugging. Most developers do not need to use the Objective-C runtime library directly when programming in Objective-C.

If your application directly calls the Objective-C runtime function objc_msgSend_stret, you need to change your code to have it work correctly on an Intel-based Macintosh.

The x86 ABI for struct-return functions differs from the ABI for struct-address-as-first-parameter functions, but the two ABIs are identical on PowerPC. When you call objc_msgSend_stret, you must cast the function to a function pointer type that uses the expected struct return type. The same applies for calls to objc_msgSendSuper_stret.

For other details on the ABI, see “32-Bit Application Binary Interface.”

If your application directly calls the Objective-C runtime function objc_msgSend, you should always cast to the appropriate return value. For instance, for a method that returns a BOOL data type, the following code executes properly on a PPC Macintosh but might not on an Intel-based Macintosh computer:

BOOL isEqual = objc_msgSend(string, @selector("isEqual:"), otherString);

To ensure that the code does executes properly on an Intel-based Macintosh computer, you would change the code to the following:

BOOL isEqual = ((BOOL (*)(id, SEL, id))objc_msgSend)(object, @selector("isEqual:"), otherString);


< Previous PageNext Page > Hide TOC


Last updated: 2007-02-26




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice