Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
linenumberstrue
languagejs
langjavascript
// create a JavaScript alias to the platform-specific property
var osname = Ti.Platform.osname;
// Booleans identifying the platforms are handy too
var isAndroid = (osname === 'android') ? true : false;

if (isAndroid) {
	// do Android specific stuff
} else {
	// do iOS, mobileweb, or other platform stuff
}

...

Code Block
languagejs
langjavascript
var isAndroid = (Ti.Platform.osname === 'android') ? true : false;
var win = Ti.UI.createWindow({
	softInputMode: (isAndroid) ? Ti.UI.Android.SOFT_INPUT_ADJUST_PAN : null
});

...

Code Block
titleAnti-pattern!
languagejs
langjavascript
var osname = Ti.Platform.osname;
if (osname !== 'android') {
   // don't assume this means iOS! It could be mobile web or some future-supported platform.
}

...