I have a simple app which also has a iOS 8 Today Extension (or widget). One of the things I am doing is sharing code classes between my app and my widget, because obviously this saves me from having to have multiple copies of the same code. It all works nicely apart from one problem I am having, one of the APIs UIApplication sharedApplication
is coming up with an error because you can't use that on iOS 8 Widgets.
So what I was thinking of, is have a simple if statement which checks if the end target is the native app OR if it is a iOS 8 widget and then add the code in as is appropriate. Would that work?
Here is my code:
if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))
{
CGSize ssz = sz;
sz = CGSizeMake(ssz.height, ssz.width);
}
How can I change this code so that is can do one of the following:
- Only run/compile IF the end target is a native iOS app and not a widget.
- OR check to see if that API is available on the target platform and then use it if it is?
I hope my question makes sense and thanks for your time, Dan.