Determine iOS version for Twitter?

Apparently my use of Twitter oAuth (request token) does not work in iOS 5 ... how can I save this code for anything below iOS 5 and use the new Twitter platform for iOS 5 +?

Is it possible to determine the version of iOS?

Thank!

+1
source share
4 answers

You (almost) never want to request iOS versions (or even frameworks). This (usually) means that you are solving the wrong problem.

In this case, you really want to know "can I use the Twitter.framework function?"

Thanks to the magic of loose connection, you can try something like:

if ([TWTweetComposeViewController canSendTweet]) {
    // Do something
}
else {
    // Use your original code
}

You can also check the components of the lower level environment, for example:

if ([TWRequest class]) {
    // Do something
}
else {
    // Use your original code
}

(, Twitter.framework .)

+6
if([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0) {
   //tweet
}
+1

First of all, the other answers are correct: you should avoid using the iOS version number to check if functions exist.

HOWEVER: located in If you really have a good reason to check the version of iOS, my favorite response to test iOS version number fooobar.com/questions/8514 / ... . So elegant.

+1
source

Determine if there is a Twitter class in installed os:

if (NSClassFromString(@"TWTweetComposeViewController")) {
   //use Twitter Framework
}

Remember to make the Twitter Framework option in the Framework list.

0
source

All Articles