0

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?

daveomcd
  • 6,367
  • 14
  • 83
  • 137

1 Answers1

2

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!

pasawaya
  • 11,515
  • 7
  • 53
  • 92
  • Sure did! Cleared some things up thanks! Quick question however... why do you recommend FMDB over Core Data... or are they separate things? Thanks! – daveomcd Jul 05 '12 at 21:36
  • 1
    @daveomcd FMDB is a wrapper around SQLite, while Core Data is a completely different way of persisting data. So yeah, they're completely different things. – pasawaya Jul 06 '12 at 00:07