iOS 呼叫通訊錄資訊

2021-07-13 14:38:33 字數 1351 閱讀 7846

abauthorizationstatus status = abaddressbookgetauthorizationstatus();

//判斷授權狀態

if (status == kabauthorizationstatusnotdetermined) else

});}else

if (status == kabauthorizationstatusauthorized)

2.獲取通訊錄裡聯絡人姓名和手機號

- (void)address

); dispatch_semaphore_wait(sema, dispatch_time_forever);

if (abaddressbookgetauthorizationstatus() != kabauthorizationstatusauthorized)

//獲取通訊錄中的所有人

cfarrayref allpeople = abaddressbookcopyarrayofallpeople(addressbooks);

//通訊錄中人數

cfindex npeople = abaddressbookgetpersoncount(addressbooks);

//迴圈,獲取每個人的個人資訊

for (nsinteger i = 0; i < npeople; i++)

else

}addressbook.name = namestring;

abpropertyid multiproperties = ;

nsinteger multipropertiestotal = sizeof(multiproperties) / sizeof(abpropertyid);

for (nsinteger j = 0; j < multipropertiestotal; j++)

//獲取**號碼和email

for (nsinteger k = 0; k < valuescount; k++)

}cfrelease(value);

}cfrelease(valuesref);

}//將個人資訊新增到陣列中,迴圈完成後addressbooktemp中包含所有聯絡人的資訊

[self

.datasource addobject:addressbook];

if (abname) cfrelease(abname);

if (ablastname) cfrelease(ablastname);

if (abfullname) cfrelease(abfullname);

}}

獲取ios通訊錄資訊

包含相應地庫之後直接呼叫 import import void readallpeoples dispatch semaphore wait sema,dispatch time forever else 取得通訊錄失敗 if tmpaddressbook nil 將通訊錄中的資訊用陣列方式讀出 n...

ios 更改通訊錄中的資訊

問題 修改通訊錄資訊時遇到這個問題 解決 提取資料 nsarray contacts store unifiedcontactsmatchingpredicate predicate keystofetch cncontactgivennamekey,cncontactimagedatakey,cn...

讀取通訊錄資訊

void readallpeoples 取得本地通訊錄名柄 abaddressbookref tmpaddressbook nil if uidevicecurrentdevice systemversionfloatvalue 6.0 tmpaddressbook abaddressbookcre...