Search code examples
iphonedebuggingtitaniumappcelerator-mobilejavascript-objects

Why can't I view an iPhone contact as Titanium Person object?


I am simply trying to see the Ti.Contacts.Person object in my log so that I can see what will be sent in an XHR POST. I start with the following:

var contacts = Ti.Contacts.showContacts({
    selectedPerson:function(e) {
        var contact = e.person;
        Ti.API.debug({message:contact.firstName}); // successfully produces 'Micah'
    }
});

If I try to see the entire object, the app crashes:

Ti.API.debug({message:contact});

The error produced is: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: id)'

I also tried to provide a JSON string to the debug method, but it is empty:

var contactString = JSON.stringify(contact);
Ti.API.debug({message:contactString}); // results in '{}'

Storing the e.person.recordId and then using this to getPersonByID doesn't help. Thanks for any suggestions.


Solution

  • It cannot be done.

    You need to pull each of the properties off of the object one by one to see what is in the contact object.

    http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Contacts.Person-object.html