To reach as many users as possible you have to check whether something exists before you try to use it. Customizing code based on iOS version number is possible, but there are other ways to do it.
Check whether some class is available, might need this with object factory and class specific protocol:
NSString *someClass = @"MyClass";Check whether class supports a method:
Class class = NSClassFromString(someClass);
if ([class conformsToProtocol:@protocol(SomeProtocol)])
{
id instance = [[class alloc] init];
[instance someProtocolMethod];
}
if ([item respondsToSelector:@selector(newMethod:)])Check whether some keyword is available:
[item newMethod:value];
else
[self workAroundFor:item with:value];
if (&UINewKey != nil)Welcome to the iReal iFragmented iWorld, iOS!
NSDictionary *dict = [info objectForKey:UINewKey];
else
NSDictionary *dict = [self generateDictInfo];
you can also check if an object supports a certain protocol:
ReplyDeleteif ([item conformsToProtocol:@protocol(SomeProtocol)])
Good addition, thanx!
ReplyDelete