0

I'm developing an iPhone application which uses standard iPhone address book (database) of contacts. I need to add some extra property to contacts but as I see iOS API does not permit addition of extra/custom properties to contacts.

Questions: 1. Is there an ability to deal with extra properties in iOS adressbook API? 2. I need expert's advice about standard approaches of how to store extra data for users/contacts: using SQLite, XML or maybe there is some data store dedicated for every application?

Exterminator13
  • 2,152
  • 1
  • 23
  • 28

2 Answers2

1

It isn't possible to append custom fields to Address Book records. You should consider looking into Core Data where you can store your custom fields mapped to a record ID.

Deepak Danduprolu
  • 44,595
  • 12
  • 101
  • 105
  • 2
    Actually that record ID is not guaranteed to be constant. From Apple's Address Book Programming Guide for iOS: "Every record in the Address Book database has a unique record identifier. This identifier always refers to the same record, unless that record is deleted or the MobileMe sync data is reset. Record identifiers can be safely passed between threads. They are not guaranteed to remain the same across devices. The recommended way to keep a long-term reference to a particular record is to store the first and last name, or a hash of the first and last name, in addition to the identifier." – PixelCloudSt Oct 01 '12 at 00:06
  • Is this still not possible in iOS 7? – bobsacameno Aug 14 '14 at 08:39
-1

Add custom property to address book.

The following code listing adds a custom property, and then removes it:

NSNumber* stringProperty = [NSNumber numberWithInteger:kABStringProperty];
NSString* testProperty = @"com.example.myProperty";
NSDictionary* dict = [NSDictionary dictionaryWithObject:stringProperty
                                                 forKey:testProperty];

NSInteger result = [ABPerson addPropertiesAndTypes:dict];
NSLog(@"Added %d properties.", result);

result = [ABPerson removeProperties:[NSArray arrayWithObject:testProperty]];
NSLog(@"Removed %d properties.", result);

More info:

https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/AddressBook/Tasks/AddingProperties.html

Fabien
  • 4,862
  • 2
  • 19
  • 33
hadi seylani
  • 117
  • 1
  • 7
  • A link to a solution is welcome, but please ensure your answer is useful without it: [add context around the link](//meta.stackexchange.com/a/8259) so your fellow users will have some idea what it is and why it’s there, then quote the most relevant part of the page you're linking to in case the target page is unavailable. [Answers that are little more than a link may be deleted.](//stackoverflow.com/help/deleted-answers) – u32i64 Aug 15 '17 at 05:46