我正在尝试获取组名称,但经过多次“由用户重新加载联系人”调用此方法后,它会给出nil
值和以下错误。
-(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
所以我使用本机通知让我知道什么时候addressbook
被修改以减少我访问的次数addressbook
,但如果用户进行多次更新并且每次addrssbook
修改必须调用这个肉类或任何其他相关的addressbook
.
所以还需要你的帮助???