iPhone 3 2-Sep-2010 10:13 AM
Edit FancyEdit New New Blog Upload All Recent Home Logout

Table Of Contents

TOP

1. compile time version checks

#pragma mark Useful Compatibility Tips
// Tip #1 Compile-time checks for OS 
/*
#ifdef _USE_OS_3_OR_LATER
// 3.0 or later defs
#endif
#if __IPHONE_OS_VERSION_MIN_REQUIRED < 30000 
// Pre-3.0 Code
#else 
// 3.0 Code
#endif

also

typedef enum {
#if __IPHONE_3_2 <= __IPHONE_OS_VERSION_MAX_ALLOWED
    UIUserInterfaceIdiomPhone,           // iPhone and iPod touch style UI
    UIUserInterfaceIdiomPad,             // iPad style UI
#endif
} UIUserInterfaceIdiom;

Built in sys versions include:
#define __IPHONE_2_0 20000
#define __IPHONE_2_1 20100
#define __IPHONE_2_2 20200
#define __IPHONE_3_0 30000
#define __IPHONE_3_1 30100
#define __IPHONE_3_2 30200
#define __IPHONE_NA 99999
*/ 
TOP

2. runtime checks

// Tip #2 Run-time checks
/* 
 // Sys prefix
 if ([[[UIDevice currentDevice] systemVersion] hasPrefix:@"2."]) 
     [cell setText:celltext];
 else if ([[[UIDevice currentDevice] systemVersion] hasPrefix:@"3."]) 
     [[cell textLabel] setText:celltext];

// key/value coding
UILabel *label = (UILabel *)[cell valueForKey:@"textLabel"]; 
if (label) [label setText:celltext];

// Class existence
Class c = NSClassFromString(classname);
if (c) {...}
*/
TOP

3. extract constants

Add these to OTHER_CFLAGS in the Build tab: -save-temps