Mac Compatibility - Suggestion
Posted: 11 Nov 2011, 15:54
I made a few tweaks to the iPhone code to get it to work on my mac.... if useful for anyone:
1) Update where you import CFNetwork.h:
2) update the handshake code to handle mac:
[/code]
1) Update where you import CFNetwork.h:
Code: Select all
//JBC: fixed imports so this works on mac too
#if defined(__MAC_OS_X_VERSION_MAX_ALLOWED)
//CFNetwork appears in CoreServices on mac
#import <CoreServices/CoreServices.h>
#elif defined (__IPHONE_OS_VERSION_MAX_ALLOWED)
//CFNetwork has its own framework on iphone
#import <CFNetwork/CFNetwork.h>
#endif
Code: Select all
//JBC: determine correct version number (different on IOS and MAC)
#if defined(__MAC_OS_X_VERSION_MAX_ALLOWED)
//piece together the version of the OS
int maj, min, fix;
Gestalt(gestaltSystemVersionMajor, &maj);
Gestalt(gestaltSystemVersionMinor, &min);
Gestalt(gestaltSystemVersionBugFix, &fix);
NSString *clientType = [NSString stringWithFormat:@"Mac version: %i.%i.%i", maj,min,fix];
#elif defined (__IPHONE_OS_VERSION_MAX_ALLOWED)
//get device system version
NSString *clientType = [NSString stringWithFormat:@"IOS version: %@", [[UIDevice currentDevice] systemVersion]];
#endif