views:

130

answers:

1

Hi,

I am developing an application to backup the whole address book into amazon s3,but i cant able to find any direct iphone api to get the whole address book into any data structure.

I tried the following code,to write the address book array to a file in document directory

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *addressPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"AddressBook.plist"];


ABAddressBookRef addressBook = ABAddressBookCreate();

NSMutableArray *allPeople = [[[(NSArray*) ABAddressBookCopyArrayOfAllPeople(addressBook)autorelease]mutableCopy]autorelease];

[allPeople writeToFile:addressPath atomically:YES];

But the problem is file is not getting created in document directory....

Any suggestions appreciated....

Thanks in advance...

A: 

Im not 100% sure, but Accessing the entire addressbook at once probably is not allowed. Apple has the AddressBookPeoplePicker for a reason, though picking everyone in the AddressBook one person at a time would be a pain.

You may be able to set up a loop to run through the address book programatically. Then add it to your own NSMutableArray.

OscarTheGrouch
Thanks for your response....yes ,only way is to traversing through whole addressbook
Fedrick