Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Diary App Using Core Data Custom UITableViewCell UIAppearance to Customize the Navigation Bar

ABAddressBook

Two things:

First:

I have a question pertaining to ABAddressBook and creating a copy of the contacts in Core Data.

I've read article after article, only to conclude with what seems to be - there is no "best approach" to working with the API and no *updated guide for storing all contacts for better access. I have looked into attempting it with mysqlite3 and, although the flat files seem relatively easy to work with, I don't want to overcomplicate a relatively simple app and have a feeling core data is the better route to go.

I am building an app that Needs to access the ABRecords of every contact, with only 3 attributes being accessed:

Name, Date Created, Phone Number.

The app then compares the date created of all the entries and organizes them into section's, just like the sample app has done here (not necessarily by months, but the same premise).

Second thing:

Ash Furrow, I am a huge fan of your collection view work and have been watching your tutorials for since starting to program, only to find that you're part of team treehouse! It would have been too perfect if you were to have put these diary entries in a collection view with a parallaxing layout, and/or added a collection view subview to the tableview cells allowing vertical and horizontal scrolling!

I am not complaining at all, like i said it would have been too perfect :]

thanks, any reference links would be greatly appreciated

Chris

Update

Any newer references of working with ABAddressBook (tutorials/github projects/stackoverflow) would be greatly appreciated

1 Answer

Ash Furrow
STAFF
Ash Furrow
Treehouse Guest Teacher

HI there,

The Address Book API is notorious in the iOS community for being difficult to work with. This is due mostly to the fact that it is a "CoreFoundation-based API". That means that it doesn't deal with normal Objective-C objects, but rather with C pointers to opaque data structures that you can only access through specific APIs. It also has significant implications for memory management when using this framework, since these C pointers aren't covered under ARC.

Probably the best source for learning how to use the library is Apple's Programming Guide on the topic.

Good luck! Ash

I have read through a majority of apple's documentation, but their samples and examples are all pertinent to accessing individual components...

If I intended on copying the address book entries into a local, more accessible storage, would you recommend using Core Data, MySQLite or just going with the basic API requests?

I have read, over and over, that the API is very slow and so doubt it will hold up, if I access it each and every time I need to display the ABRecords and the 4, or so properties I will need.

(Note*) I am tying it into a collection view, where the ABRecords populate the cells and they are separated into sections.

Ash Furrow
Ash Furrow
Treehouse Guest Teacher

Hi again, Chris. I don't know if storing the records in a Core Data cache would be the best idea, since you'd have to constantly be updating your records anyway. I think, for only having those four pieces of information, keeping an in-memory store, or even not using Core Data at all, would be the simplest solution.

I haven't heard that the API is slow, but I've only briefly ever used it. That programming guide contains an example that should be pertinent to your situation.