Domanda

I want to export my contacts from gmail into a csv file.. Then upload that onto my server. Now, I want my app to be able to import the csv from my server and save into the app. Because my contacts list gets updated often, therefore I would like the app to be updated. Basically I want my app to be like the iPhones AdressBook. But when a name is clicked it opens up mail app and allows a message to be sent to the contact.

Is this possible, and how may I go about accomplishing this ?

Thank You.

È stato utile?

Soluzione

The short answer is "YES", but a lot of this depends on how you want to store your contacts in your application (i.e. this answer could change from one application to the next, and nobody here knows what your application does or how it implements details).

But to get started, you could load the CSV file into a NSString object via:

NSString * myCSVfile = 
    [[NSString alloc] initWithContentsOfURL: [NSURL URLWithString: @"http://www.myserver.org/mycontactsfromgmail.csv"]];

and then split the contacts into an array via:

// We're assuming you are using commas to separate the gmail addresse
NSArray * myGMailContactsArray = [myCSVfile componentsSeparatedByString: @","];

And using this array, you can store your gmail contacts into your app any way you wish.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top