Apparently, my use of Twitter oAuth (token request) doesn't work in iOS 5... how can I keep this code for anything below iOS 5 and use the new Twitter Framework for iOS 5+?
Is it possible to detect iOS versions?
Thanks!
Apparently, my use of Twitter oAuth (token request) doesn't work in iOS 5... how can I keep this code for anything below iOS 5 and use the new Twitter Framework for iOS 5+?
Is it possible to detect iOS versions?
Thanks!
You (almost) never want to query iOS (or even framework) versions. That (usually) means you're solving the wrong problem.
In this case, you really want to know "can I use Twitter.framework?"
Thanks to the magic of weak linking, you can try something like:
if ([TWTweetComposeViewController canSendTweet]) {
// Do something
}
else {
// Use your original code
}
You can also check for lower level framework components, e.g.:
if ([TWRequest class]) {
// Do something
}
else {
// Use your original code
}
(Obviously you will need to link against Twitter.framework and include the requisite headers.)
if([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0) {
//tweet
}
First and foremost, the other answers are correct-- you should avoid using iOS version number to check if features exist.
HOWEVER: In case you do indeed have a good reason to check iOS version, my all-time favorite answer for checking iOS version number is in this StackOverflow answer. So elegant.
Detect if the Twitter class is in the installed os :
if (NSClassFromString(@"TWTweetComposeViewController")) {
//use Twitter Framework
}
Do not forget to make the Twitter Framework optional in the list of Frameworks.