Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Ti.App.Properties.set/getObj not retaining new value

$
0
0

Mobile Titanium 3.1.2 IOS Simulator 6.0 & Device IPhone 4S Mac OS X

I'm having trouble changing a value in my object array. On user login I set an object array using this line of code:

var user = JSON.parse(e.data); var userObj = {}; userObj.id = user.id; userObj.username = user.name; userObj.fname = user.first_name; userObj.lname = user.last_name; userObj.email = $.email.value; userObj.password = $.password.value; userObj.pic = user.profile_pic; Ti.App.Properties.setObject('userData', userObj);

And then in another .js file, the user needs to be able to change their user profile pic. I then need the object 'userData' to hold the new userObj.pic value for other areas of the app. So on the .js file in which a user can change their image, I have this code that runs upon API call success(API to post new image to server):

``` var user = JSON.parse(e.data);

    var userObj = {}
    Ti.App.Properties.setObject('userData', userObj);

    var userObj = {};
                var userObj = {};
                userObj.id = user.id;
                userObj.username = user.name;
                userObj.fname = user.first_name;
                userObj.lname = user.last_name;
                userObj.pic = user.profile_pic;
                Ti.App.Properties.setObject('userData', userObj);

```

And I have made sure that the new image has been uploaded to the server, so I know it is there. I have emptied the userObj array and refilled it will the new API call containing the new image, however when I leave the page and try and use the new userObj (var userObj = Ti.App.Properties.getObject('userData')) in other areas of the app it has the old image attached to it still. How do I change an array item value so that it sticks?


Viewing all articles
Browse latest Browse all 8068

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>