I’m a noob on IOS, and I’m trying to pass all contacts from iphone (simulator) to a table. I’ve followed some tutorials, but I’m getting an error.
Can you help me with that?
I’ve tried it:
#import <AddressBookUI/AddressBookUI.h>
.
.
.
ABAddressBookRef addressBook = ABAddressBookCreate( );
CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople( addressBook );
CFIndex nPeople = ABAddressBookGetPersonCount( addressBook );
for ( int i = 0; i < nPeople; i++ )
{
ABRecordRef ref = CFArrayGetValueAtIndex( allPeople, i );
NSLog(@"%@",ref);
}
I get this errors:
Undefined symbols for architecture i386:
"_ABAddressBookCreate", referenced from:
-[younifyTableViewController viewDidLoad] in younifyTableViewController.o
"_ABAddressBookCopyArrayOfAllPeople", referenced from:
-[younifyTableViewController viewDidLoad] in younifyTableViewController.o
"_ABAddressBookGetPersonCount", referenced from:
-[younifyTableViewController viewDidLoad] in younifyTableViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
You need to link your project with the AddressBook framework. In Xcode, navigate to your project settings (the top-level item in the file browser), go to the “Build Phases” tab, expand the “Link Binary With Libraries” section, click the “+” icon, select “
AddressBook.framework,” and click OK. This should fix your problem.The error message you see tells you that when compiling your app, it can’t find the symbols listed. These symbols are declared in the AddressBook headers you’ve imported, but they’re implemented in the framework, which is why you need to link to it. The linking process fills in these symbols.