Jackson Tale
Jackson Tale

Reputation: 25812

xcode - The relationship of SDK version and users' iPhone OS versions

This question might be simple.

So, if I use some new class in the new SDK, should I assume my app can run only on iPhones with the same OS version number or above?

For example, if I use a class whose document says this class exists only after iOS 5, should I assume my app can run only on iPhone with iOS 5?

or the term iOS 5 in the class document refers to only the SDK, not the target deploy platform?

Upvotes: 2

Views: 139

Answers (2)

Angel G. Olloqui
Angel G. Olloqui

Reputation: 8105

Deployment target, iOS and SDK are not the same concept, but they are related. When you see that a method or a class is available in iOS5 that means that you will need to have a SDK5 in your machine in order to compile it, and that the user needs an iOS5 in their device in order to execute it. However, you could have a deployment target below it (iOS4 for example) and just take care on runtime to not execute that part of the code.

There is a lot of detailed information of how to do it out there, but in brief:

  1. If it is a method, check before calling that it responds to the method: [object respondToSelector:@selector(yourNewMethod)]

  2. If it is a class, check before instantiate the object that the class exists: NSClassFromString(@"YourNewClass"). Additionally, if the class is in a new framework not present in your old deployment target, remember to link it as a "weak" framework. Otherwise it will fail when starting.

Of course, in both cases, you need to give an alternative response to the user.

Upvotes: 3

CBredlow
CBredlow

Reputation: 2840

The term iOS 5 refers to the operating system on the device. So, that class would only work on devices post 5 and until it is deprecated.

Upvotes: 0

Related Questions