Ti.API.info(array) causing crash

You must Login before you can answer or comment on any questions.

Hi

Am I just missing something or what, but when I try to print out the value of an array out to the debug console the app crashes?

Here is the code:

var myArr = [];
 
myArr = Ti.App.Properties.getList('myArr');
 
// At this point I can see my objects being added to the array
 
Ti.API.info(myArr); // Causing crash [NSArrayM characterAtIndex]: unrecognized selector sent to instance
Even if I try to print out a specific property of my object out of the array I'm still getting the same error:
Ti.API.info(myArr[0].email);
Any ideas?

1 Answer

Accepted Answer

If had the same error and came up with this solution. Basically I test the array before using it

var restoredUserInfo = JSON.parse(Ti.App.Properties.getString('ThisUser'));
if (restoredUserInfo) {
    if (restoredUserInfo.myname!='') {
        alert('Welcome Back ' + restoredUserInfo.myname);
    }
}

Your Answer

Think you can help? Login to answer this question!