Reputation: 6565
I'm wanting to store some contact information and allow the user to call/email the person instead of just looking up the info. I don't want the contacts stored in the user's Address Book in their contacts though. I want to keep it within the app only. Can I use ABAddressBook for this or do I need to create my own classes to accomplish this?
Upvotes: 0
Views: 574
Reputation: 11595
I'll address both your questions:
Can I use ABAddressBook for this?
You cannot use ABAddressBook to store a separate contacts database. Here's an excerpt from the ABAddressBook Class Reference:
The ABAddressBook class provides a programming interface to the Address Book—a centralized database used by multiple applications to store contact and other personal information about people.
The database referred to here is a pre-specified database; there is no method or class to create a new one, as the whole Address Book framework provides access to a single database accessible to the user through the Contacts application.
Do I need to create my own classes to accomplish this?
You would need to create a custom class for this. If you plan on supporting users with many, many contacts (in the thousands/high hundreds range), you probably would use an SQLite database. If you plan on supporting users with few contacts, you should probably use a .plist.
Usually, Objective-C programmers use the C library for SQLite directly, but now there is a great wrapper that you can find here called FMDB.
For info on the syntax and basics of SQLite, see the SQLite Language Guide.
Lastly, here are a couple books on SQLite and database programming for iOS:
Hope this helps!
Upvotes: 2