iPhone: Accessing Composite Name in AddressBook Causes EXC_BAD_ACCESS
- by Fyrian
Hi everyone. I'm new to iPhone development and have a question I hope someone can help me with.
I have a programmer working on an iPhone app for me and when I run the app in the simulator, it works great. But when I try to run it on my actual iPhone, I get a EXC_BAD_ACCESS error and the app locks up.
Looking at the debugger, it's referencing the following code in my MainController as the problem:
-(void)loadAddressBook{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
addressBookLoaded=1;
[AddressbookRecord readAllContactTable:[self getDBPath]];
ABAddressBookRef addressBook = ABAddressBookCreate();
for(NSUInteger i=1;i<=ABAddressBookGetPersonCount(addressBook);i++) {
ABRecordRef myPerson =ABAddressBookGetPersonWithRecordID (addressBook,(ABRecordID)(i));
NSString *name = (NSString*)ABRecordCopyCompositeName(myPerson);
//save in database
AddressbookRecord *addObj = [[AddressbookRecord alloc] initWithPrimaryKey:0];
addObj.ClientName=name;
[addObj addNewContactEntry];
}
addressBookLoaded=2;
[pool release];
}
More specifically, it points to this specific line as the problem:
NSString *name =(NSString*)ABRecordCopyCompositeName(myPerson);
My programmer can't seem to figure out what the problem is since he can't replicate it on his end. Does anyone have any ideas what would cause this problem???
Thanks!