Correct way to set up an addressBook instance variable?

Maybe someone can answer this one easily. I working on an iphone app where to get info for each row in cellForRowAtIndexPath I was creating a new address book each time calling:

ABAddressBookRef addressBook = ABAddressBookCreate();

This works fine other than it's slow and does not feel right to be creating a new ab for each row. So I created an addressBook instance variable but can't seem to use it without crashing. (Program received signal: “EXC_BAD_ACCESS”.) I imagine that I'm not setting it up right, but have have had no luck finding anything specifically about this in the documentation.

Thanks a million in advance to anyone who can help.

In my .h file I did this:

ABAddressBookRef addressBook;

@property(nonatomic, readwrite) ABAddressBookRef addressBook;

Then in my .m file:

    if (self = [super initWithStyle:style]) {

        addressBook = ABAddressBookCreate();

    return self;


When do you release the addressBook by CFRelease(addressBook) ? If the memory is not enough, the ABAddressBookCreate() will return a nil object. The C-based addressBook.framework API cannot work with nil object, and it will crash with "EXC_BAD_ACCESS".

Need Your Help

Scala eclipse plugin Problem

scala compiler-construction eclipse-plugin

I install the scala eclipse plugin, but it make me annoyed

How would I load different slides on a page depending on which link the user clicks?

javascript jquery ajax wordpress

I'm trying to create a site like this on WordPress where you have multiple slides (the navigation on top call the different slides) that fade in/out based on which link is clicked by the user. I'm

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.