What is a good way to write classes that can be used in both iOS and Mac OS applications? I'm not trying to get a full cross-platform UI solution here, just a way to use several model classes from my iPhone app in a support application running on the Mac. Some of those classes require a few minor changes to get them compiling under Mac OS. This seems like a call for macros, but I don't know which ones are typically used. Any suggestions or shared experience would be appreciated.
Asked
Active
Viewed 453 times
1 Answers
8
One way is like this example from a iOS/OSX multi-platform class header file:
#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#else
#import <Cocoa/Cocoa.h>
#endif TARGET_OS_IPHONE

Ben
- 2,982
- 1
- 16
- 12
-
2Thanks, Ben! That's exactly what I was looking for. For those who are interested, the other macro is `TARGET_OS_MAC`. – James Huddleston Oct 20 '10 at 22:58