开发者

Accessing whole Iphone addressbook

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];

[allPeo开发者_如何学Pythonple writeToFile:addressPath atomically:YES];

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

Any suggestions appreciated....

Thanks in advance...


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.


You would require this function: http://developer.apple.com/library/ios/#documentation/AddressBook/Reference/ABPersonRef_iPhoneOS/Reference/reference.html#//apple_ref/doc/uid/TP40007210

An Array of all the people is returned. Read the documentation for more. Best of Luck!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜