Time for action – running the Android menu changes on iOS
If you are running on a Mac and have the iOS SDK installed, try running the app on the iOS emulator.
What just happened?
The app will fail to run. The red screen of death that will become familiar as you code your apps will be displayed.
Why did this fail?
The line that caused the error is as follows:
var activity = win.activity;
An iOS window has no concept of an activity. The activity property will not be available on iOS. The Appcelerator documentation is clear in this respect; the documentation shows that the activity property only exists on Android as shown in the following image:
You have to handle this platform-specific code yourself. Fortunately, it's not hard to do and if you are developing a cross-platform app it is a concept you will use often.
Isolating platform-specific code
When you have platform-specific code you have to have some way of avoiding executing it on the wrong platform. This usually means wrapping the code in an...