I have an iOS 5 application, now built with Xcode 4.5, I am running it on iphone 5.0 simulator.
The Xcode target is correctly set to iOS 5, while the base sdk is iOS 6, and there’s no way to change within Xcode.
There’s a fragment of code which made use of the enum.
UIInterfaceOrientationMaskAll
I am not really using that enum in my code, it’s a mistake I did, that lead me to ask some questions:
-
I would expect the compiler stop building, because it’s available starting from iOS 6, and telling me that the enum is not to be found.
-
Then, by running the app in simulator (iphone 5.0 simulator), I would also expect the app crashing at runtime when dealing with that enum.
Nothing of that is hapenning, and the app compile and runs just fine, could you please explain what am I missing ?
Here’s my explanation.
Looking at the documentation, all the
UIInterfaceOrientationvalues are available from iOS 6.0. You are supposed to return them fromUIApplication‘ssupportedInterfaceOrientationsForWindow:, which is also available from iOS 6.0.Since your base SDK is 6.0, you have the new version of the header file (
UIApplication.h) that defines theenumvalue. That’s why your app compiles.When you run the app on the iPhone 5.0 simulator, nobody ever calls the aforementioned method, because it didn’t exist in 5.0. Even if you had subclassed
UIApplication, and had implemented that method, it wouldn’t be called, so your app won’t crash with unknown selector. It could also be implemented by your app delegate.Also, the
enumvalue is just a number after compilation anyway, so there is no “dealing with” that would cause a problem, unlike missing interfaces would.But if I’m totally off base, I’m sure somebody will set me straight.