Tag Archive for 'easy'

Runtime iOS Version Checking

Simple preprocessor macros to detect the current iOS version at runtime.

The NSNumericSearch compare option is very clever and can evaluate various types of numeric strings, including period separated integer strings!

Source

/*
 *  System Versioning Preprocessor Macros
 */ 

#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

/*
 *  Usage
 */ 

if (SYSTEM_VERSION_LESS_THAN(@"4.0")) {
    ...
}

if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"3.1.1")) {
    ...
}

Pull-to-Refresh ListView for Android

Although this kind of list refreshing is rather an iPhone feature, and not really used on Android platform, sometimes it is requested to use.
An easy to use listener-based implementation can be found here by Johan Nilsson.
Alternative version thanks to Guille Polito.

Update here is another lib, used in Friendcaster and co: Android-PullToRefresh by Chris Banes