Generating Address Book Contacts on iPhone Simulator with MonoTouch

One of the things that I needed for testing my app was a list of contacts to play around with in the Contacts app on the iPhone simulator. The only way to do this is to either manually input contacts — which I am not willing to do for 50+ contacts — or programmatically add them in with a bit of random data.

I have done the latter. Check out the monotouch-generate-contacts project on github. This app, once run on the simulator, will add 50 contacts into the address book and generate some random phone numbers for each contact.

For those of you that don’t care about the project on git hub, here’s the main gist of how you add a contact to the address book.

var addressBook = new ABAddressBook();
var record = new ABPerson();
record.FirstName = "Marco";
record.LastName = "Polo";
var phones = new ABMutableStringMultiValue();
phones.Add("4566545555", ABPersonPhoneLabel.Mobile);

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: