Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-322] Support setObject/getObject in Properties API

GitHub Issuen/a
TypeNew Feature
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2012-05-04T11:42:37.000+0000
Affected Version/sRelease 1.7.0
Fix Version/sRelease 2.1.0
ComponentsiOS
Labelsapi, module_app_properties, qe-testadded
ReporterJames K
AssigneeDawson Toth
Created2011-04-15T02:27:17.000+0000
Updated2012-06-05T15:37:49.000+0000

Description

This is a feature request for:

Titanium.App.Properties.setObject(obj)
Titanium.App.Properties.getObject(obj)

At present, if we want to store a non-array object (such as a hash map) we have to create an array containing a single element which holds the object, and then use setList and getList.

This is a bit messy and it would be much easier if we could simply store the object directly.

Thanks

Edit: Someone has already tried to write their own custom methods http://support.appcelerator.net/discussions/support/399-adding-an-object-to-appproperties"> here.

Comments

  1. Stephen Tramer 2011-04-15

    Invalidated by the flow of time...

  2. Dawson Toth 2011-05-18

    Could I rekindle the discussion about this? "Invalidated by the flow of time..." is a bit vague for my taste; is this something we could support? The use case is still very valid, and it would simplify a lot of code.
  3. Dawson Toth 2011-05-18

    What does "Invalidated by the flow of time..." mean? I believe this could be very useful to our customers.
  4. Dawson Toth 2012-04-27

    Sent in a PR for this: https://github.com/appcelerator/titanium_mobile/pull/2093 Used this code to test, worked on iPhone Simulator 5.1, Android device EPIC 4G 2.3.7, and Chrome with Mobile Web.
       try {
           // Test getting objects.
           var getObj = Ti.App.Properties.getObject('MyGetObject', { key: 'get works!' });
           assert('get works!', getObj && getObj.key);
       
           // Test setting objects.
           Ti.App.Properties.setObject('MySetObject', { key: 'set works!' });
           var setObj = Ti.App.Properties.getObject('MySetObject');
           assert('set works!', setObj && setObj.key);
       }
       catch (err) {
           alert('FAIL! ' + err);
       }
       
       function assert(expected, actual) {
           if (expected == actual) {
               alert('PASS! expected and actual: "' + actual + '"');
           } else {
               alert('FAIL: expected "' + expected + '", actual: "' + actual + '"');
           }
       }
       
  5. Josh Roesslein 2012-05-01

    Dawson, Could you port this test case into drillbit/tests/properties.js? This seems like something we can automate in our test suite. If you could add this to your PR that would be great.
  6. Vishal Duggal 2012-05-04

    Fixed by PR 2093
  7. Wilson Luu 2012-06-05

    Closing feature. Was able to verify App.Properties.getObject and App.Properties.setObject behave as expected on: SDK build: 2.1.0.v20120604151821 Titanium Studio, build: 2.1.0.201206041625 Runtime: v8 xcode: 4.3.2 Device: Droid 1 (2.2.3), iphone 4s verizon (5.0.1)

JSON Source