Page 1 of 1

How can I code device-specific?

Posted: Wed May 01, 2013 4:42 pm
by DevBoyLars
Hi there,
is it possible to tell the compiler which code is for which device?

Such as to use native-scroller on iOS and Android in one App with one code :)

Re: How can I code device-specific?

Posted: Wed May 01, 2013 5:24 pm
by Dixie
look at 'systemVersion' in the dictionary.. and then act accordingly depending on what result the 'systemVersion' function returns.

Dixie

Re: How can I code device-specific?

Posted: Wed May 01, 2013 5:27 pm
by CoffeeCone
DevBoyLars wrote:Hi there,
is it possible to tell the compiler which code is for which device?
Yes, you can run specific codes for specific devices by using the platform function like so:

Code: Select all

if the platform is "android" then
  // do this
else if the platform is "iphone" then
  // do this
end if

Re: How can I code device-specific?

Posted: Wed May 01, 2013 6:16 pm
by DevBoyLars
Nice, so does it mean, I can convert a normal scroller to a native-iOS scroller at runtime or pre-compiled?

Re: How can I code device-specific?

Posted: Wed May 01, 2013 6:25 pm
by CoffeeCone
DevBoyLars wrote:Nice, so does it mean, I can convert a normal scroller to a native-iOS scroller at runtime or pre-compiled?
I haven't developed for mobile yet using LC. Perhaps, other people here can help out. But basically, that's what you use for detecting the platform the app is running on.

Re: How can I code device-specific?

Posted: Wed May 01, 2013 7:00 pm
by Dixie
Yes, apologies... 'platform' is correct... wasn't thinking, obviously.. :oops: