iPhone Create Contact

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

Hey guys,

i currently am unable to create a contact within my iPhone app.

This is the code i use.

var contact = Titanium.Contacts.createPerson();
contact.firstName = companyname+' - ';
contact.lastName = shortcutname;
contact.note = shortcut;
Titanium.Contacts.save();
});
This adds a contact fine, but as soon as i add "contact.phone" the app crashes.

Anyone know the reason why?

-Tom

3 Answers

Thats awesome, got it working now fine!

Is there anyway of setting an ID of a contact, so i can check within the app if the contact has already been added or not, to stop duplicates!

Thanks

Ok, here my structure in iOS, after caling the app crashes:

var contact = Ti.Contacts.createPerson({
    URL : {
        "homepage" : 'http://vladi.de'
    },
    phone : {
        "work" : ['004940330000']
    },
    email : {
        "work" : ['info@vladi.de']
    },
    lastName : 'Vladi Private Islands',
    kind : Ti.Contacts.CONTACTS_KIND_ORGANIZATION,
    address : {
        "work" : {
            "Street" : 'Ballindamm 7',
            "City" : 'Hamburg',
            "State" : 'Hamburg',
            "ZIP" : '2000'
        }
    }
});
with -[__NSCFString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0xa0885b0

Whats going wrong?

— answered 2 years ago by Rainer Schleevoigt
answer permalink
2 Comments
  • I have the same problem. Either in iPhone Simulator or iPhone device this is crashing my application with this error message (Simulator): "-[KrollCallback countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x8d87820" It creates only a blank contact on iPhone.

    — commented 2 years ago by Benjamin Philipp

  • I am having the same @Rainder did you find any solution?? please provide. I am using the following code to create contact. App crashes contacts are saved properly but app crashes. why? any solution?

    var contact = Titanium.Contacts.createPerson();
                    contact.firstName = cat_name;
                    contact.organization = cat_organization;
                    contact.kind = Titanium.Contacts.CONTACTS_KIND_ORGANIZATION;
                    var address = {};
                    address.Street = cat_addr;
                    address.City = cat_city;
                    address.State = cat_state;
                    address.ZIP = cat_zip;
     
                    contact.address = {"work":[address]};   
                    contact.email = {"work": [cat_email]};
                    contact.phone  = {"work": [cat_phone]};
     
                    Titanium.Contacts.save(contact);
     
                    Titanium.UI.createAlertDialog({ 
                        title:'Contact added',
                    }).show();

    — commented 4 months ago by Nadeem Mughal

Your Answer

Think you can help? Login to answer this question!