Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ABAddressBookCreate() , ABAddressBookGetGroupCount , ... return @"0x00000000 <nil>"?

I'm trying to get Groups Name but after many time call this method "by the user to reload contacts" it give the nil value and the following error.

-(void) getGroupsName
    {
        [groupsName removeAllObjects];
        //address book object to interact with iPhone contacts.
        ABAddressBookRef addressbook = ABAddressBookCreate();
        //get groups count
        CFIndex groupsCount          = ABAddressBookGetGroupCount(addressbook);
        //get all available groups as array
        CFArrayRef allGroups         = ABAddressBookCopyArrayOfAllGroups(addressbook);

        for (int i = 0; i<groupsCount; i++) {
            //get group of index=i from groups array
            ABRecordRef group = CFArrayGetValueAtIndex(allGroups, i);
            //get group name, I use __bridge_transfer to transfer from C to objective-c.
            [groupsName addObject:(__bridge_transfer NSString*)ABRecordCopyCompositeName(group)];

        }
        CFRelease(allGroups);
        CFRelease(addressbook);
    }
//////////////////////////////////////////////////////////////

    warning: Could not compile statement PRAGMA journal_mode = wal;: unable to open database file error 14 creating properties table: unable to open database file warning: Could not compile statement SELECT value FROM _SqliteDatabaseProperties WHERE key = ?;: unable to open database file warning: Could not compile statement SELECT value FROM _SqliteDatabaseProperties WHERE key = ?;: unable to open database file warning: Could not compile statement SELECT value FROM
_SqliteDatabaseProperties WHERE key = ?;: unable to open database file warning: Could not compile statement SELECT ROWID, First, Last, Middle, NULL, NULL, NULL, Organization, NULL, NULL, Kind, NULL, NULL, Nickname, Prefix, Suffix, FirstSort, LastSort, CreationDate, ModificationDate, CompositeNameFallback, NULL, StoreID, NULL, FirstSortSection, LastSortSection, FirstSortLanguageIndex, LastSortLanguageIndex, NULL, NULL, NULL, PersonLink, NULL, IsPreferredName FROM ABPerson;: unable to open database file warning: Could not compile statement SELECT ROWID, First, Last, Middle, NULL, NULL, NULL, Organization, NULL, NULL, Kind, NULL, NULL, Nickname, Prefix, Suffix, FirstSort, LastSort, CreationDate, ModificationDate, CompositeNameFallback, NULL, StoreID, NULL, FirstSortSection, LastSortSection, FirstSortLanguageIndex, LastSortLanguageIndex, NULL, NULL, NULL, PersonLink, NULL, IsPreferredName FROM ABPerson;: unable to open database file warning: Could not compile statement INSERT OR REPLACE INTO _SqliteDatabaseProperties VALUES (?, ?);: unable to open database file warning: Could not compile statement SELECT value FROM
_SqliteDatabaseProperties WHERE key = ?;: unable to open database file warning: Could not compile statement INSERT OR REPLACE INTO
_SqliteDatabaseProperties VALUES (?, ?);: unable to open database file warning: Could not compile statement SELECT value FROM
_SqliteDatabaseProperties WHERE key = ?;: unable to open database file warning: Could not compile statement SELECT value FROM
_SqliteDatabaseProperties WHERE key = ?;: unable to open database file warning: Could not compile statement SELECT ROWID FROM ABGroup;: unable to open database file warning: Could not compile statement SELECT ROWID, Name, ExternalIdentifier, StoreID, NULL, NULL, NULL FROM ABGroup;: unable to open database file

So I use the native notification to let me know when addressbook get modified to decrease number of time I access the addressbook, but still not good by the time if user make many update and every-time addrssbook get modified must call this meathod or any other one related to addressbook.

so still need your help ???

like image 608
Omarj Avatar asked Dec 23 '12 10:12

Omarj


1 Answers

ABAddressBookCreate has been decprecated in iOS6. Use ABAddressBookCreateWithOptions, it will return a CFErrorRef object if you don't have access to the address book.

like image 132
thelaws Avatar answered Nov 13 '22 15:11

thelaws