Our app can share items to facebook. We'd like to share to twitter too, but we don't want to use a thrid-party solution now that there's an official twitter framework. However, we don't want to make the app depend on iOS5 - what we'd like is to show a Twitter and Facebook button on iOS 5, but just the Facebook button on iOS 4. Is that possible? If so, what project settings do we need and how do we selectively show the button?
Asked
Active
Viewed 759 times
1 Answers
11
Rather than testing for a specific iOS version, Apple recommends testing for specific functionality when you need to degrade gracefully to support earlier versions. To do this you can weakly link the Twitter framework then test for its availability using:
if ([TWRequest class]) {
// Twitter framework is available: Enable button etc.
} else {
//Twitter framework is not available: Hide twitter button etc.
}
You would probably do this in the viewDidLoad method of the relevant view controller to configure your UI.
Have a look at the documentation for using weakly-linked classes.

Robin Summerhill
- 13,695
- 3
- 41
- 37
-
For those of you who are curious *how* to weakly link a framework: http://stackoverflow.com/a/6480788/194707 – kevlar Jun 12 '12 at 08:10