- (void)requestAuthorizationForAddressBook {
ABAddressBookRef addressBook =ABAddressBookCreateWithOptions(NULL, NULL);
ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) {
if (granted) {
NSLog(@"授權(quán)通訊錄成功!");
} else {
NSLog(@"授權(quán)通訊錄失敗!"); }
});
CFRelease(addressBook);
}
CFRelease(addressBook);這行會時不時的崩潰掉,因為adressBook?有時是一個僵尸對象喳挑。所以應(yīng)當(dāng)判斷是否為nil,再選擇性去釋放