Properties.getInt on Android error?
I'm getting an error on Android only when trying to use properties.getInt().
On the first page i set a property, which is getting an id from a database query result set:
//Set a property so that we can refer back to it
Ti.App.Properties.setInt("category",e.rowData.id);
Then on the following page i retrieve the property:
//Get property value we set earlier
var categoryId = Titanium.App.Properties.getInt("category");
In the emulator & on a real Android device I get:
"Wrapped java.lang.IllegalArgumentException:argument type mismatch"
I'm guessing that this should work fine. However looking at the KitchenSkin code I see that they are retrieving all of the setters using getString even when the property is set using setInt()?
Is this a known bug? Is the answer to get all set properties as Strings when I really need an int?
UPDATE I am now sure this is a bug. getString works fine getInt crashes the app in Android.
1 Answer
-
Same issue with getBool(), 4 weeks old anyone have any tips?
Edit-> Found this in the sample:
Titanium.API.info('String: '+ Titanium.App.Properties.getString('String'));
Titanium.API.info('Int: '+ Titanium.App.Properties.getString('Int'));
Titanium.API.info('Bool: '+ Titanium.App.Properties.getString('Bool'));
Titanium.API.info('Double: '+ Titanium.App.Properties.getString('Double'));They're using getString for everything.
The documentation shows:
http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.App.Properties.getBool-method.html
http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.App.Properties.getInt-method.html
So this is a bug in my opinion.
Confirmed workaround, set the default value which is used if the setting is not found:
if (Ti.App.Properties.getBool('geo.testmode',false) === true) { }