Reputation: 4036
I am fairly new to iOS development and just completed my first app using the iOS5 SDK and Xcode 4.2. The problem now is that my app will require users to upgrade to iOS5 because I used the Storyboard API to create the UI for the app. Storyboard is only available in iOS5.
My question is, how do I make my App backward compatible with at least iOS4? Is it as simple as just creating the UI using nib files? Can someone give me pointers to an example on how to go about this?
Also, are there other similar pitfalls that I need to be aware of that will make my app backward incompatible?
Upvotes: 1
Views: 1795
Reputation: 49
You should look into https://github.com/doubleencore/DETweetComposeViewController. It is an iOS4 compatible re-implementation of the TWTweetComposeViewController.
Upvotes: 0
Reputation: 22939
Generally if you want to be backwards compatible you should:
Link frameworks weakly. For example the Twitter.framework
is only available in iOS > 5.0 so mark the framework as optional
in Xcode's Link Binary with Libraries
section.
Import the framework's headers as usual
#import <Twitter.Twitter.h>
Instead of checking "Is the OS version bigger than 5.0" you should rather check like this:
Is the class with a specific name available:
Class TWTweetClass = NSClassFromString(@"TWTweetComposeViewController");
if (TWTweetClass){
// Use the new stuff
TWTweetComposeViewController *tweetSheet = [[TWTweetComposeViewController alloc] init];
// etc.
} else {
// Handle the case when the class is not available
}
Does a given object respond to a selector:
if([someObject doesRespondToSelector:@selector(someNewlyAvailableSelector:)]){
[someObject performSelector:@selector(someNewSelector:)];
}
This works fine with the Twitter framework, however, storyboarding is different in that respects as it is not like an optional framework that you can check for on runtime. If you want to use storyboarding your users have to have at least iOS version 5.0.
Upvotes: 4
Reputation: 3020
The UIStoryboardSegue is iOS 5 only does the app will not run on iOS 4. Since it not a compile time feature, you will have to go back to using NIB's.
Any methods you use that are only available in iOS 5 will not work in iOS 4, thus meaning that any methods that deal with the storyboard will not work in iOS 4.
Upvotes: 0