Search code examples
titaniumappceleratortitanium-mobileappcelerator-mobile

Titanium Properties API usage


I'm new to Titanium Properties API. I'm getting a weird error when using setObject() method. Following is my code.

Titanium.App.Properties.setObject(view.idAttr, view);

Where view.idAttr is a string acting as a key for this property and view is a View type object. Upon calling above method, I get following message.

2012-09-14 17:47:25.947 SumMeUp[14033:4a03] *** -[NSUserDefaults setObject:forKey:]: Attempt to insert non-property value '[object TiUIView]' of class 'TiUIViewProxy'.  Note that dictionaries and arrays in property lists must also contain only property values.

I couldn't understand this behavior. If anyone knows a solution to, please reply.

Thanx


Solution

  • setObject() is meant for objects only, not for views.

    A object would be something you write yourself in JavaScript.

    Even if it could, it would be bad behaviour of the app to store it in a property. Remember the property is being stored cross-session. So if you want something stored, store data there to generate the view later again, not the view itself. Also saves a lot of memory!