Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Titanium.App.Properties.setList fails for objects?

I have been using Titanium.App.Properties.setList successfully with arrays of strings, but I can't make it work for a JS object with several key:value pairs. Isn't this an allowed use? This is with the new 1.0 bits.

— asked March 10th 2010 by Bruce Martin
  • objects
  • properties
  • setlist
0 Comments

3 Answers

  • I see now that I was wrong in trying to setList the {key:value} object itself. I see that I have to put the object into an array list, like this: Array[0]=Obj; and then setList the Array. Right?

    UPDATE: putting the object into an array list, like this: Array[0]=Obj has been working for me under 1.0. This way I can setList the property and then getList the property in another window to pass the object, which has several key:value pairs.

    — answered March 10th 2010 by Bruce Martin
    permalink
    0 Comments
  • Hi Bruce, that's right. Although I thought I encountered an issue whereby a single object wasn't getting stored because it wasn't getting recognised as an array of one. There are probably workarounds in JS to force that.

    cheers,
    Chris.

    — answered March 10th 2010 by Chris Reed
    permalink
    0 Comments
  • Actually researching this one again it might be better to assign the array to the window when it's created

    similar to:
    http://developer.appcelerator.com/question/501/passing-objects-to-other-windows

    If you do use properties bear in mind they are persistent i.e. will hold their values between sessions, so you might need to empty/remove them on exit (or startup)

    — answered March 10th 2010 by Chris Reed
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.