gpt4 book ai didi

ios - 授予地址簿访问权限后,将用户联系人存储在 NSMutable 数组中

转载 作者:行者123 更新时间:2023-11-29 03:21:08 25 4
gpt4 key购买 nike

我在我的 viewWillAppear: 中使用它来请求用户允许/访问(如 apple 要求的那样)他们的地址簿。当他们允许访问时,他们可以进入“邀请”页面,在那里他们可以浏览(他们自己的)已经在我的应用上拥有帐户的联系人。基本上,我将获取他们的联系人并将其放入 UITableView 中。所以,我必须获取所有他们的联系人并将其添加到NSMutableArray 类型的数组中。在下面的代码中,它显示“//将所有用户联系人添加到此处阵列”,我需要一些代码。我在那里放什么?

- (void)viewWillAppear:(BOOL)animated
{
// Request authorization to Address Book
ABAddressBookRef addressBookRef = ABAddressBookCreateWithOptions(NULL, NULL);

if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined) {
ABAddressBookRequestAccessWithCompletion(addressBookRef, ^(bool granted, CFErrorRef error) {
if (granted) {
// First time access has been granted, add user's contacts to array
// ADD ALL OF USERS CONTACTS TO ARRAY HERE

} else {
// User denied access
// Display an alert telling user that they must allow access in order to proceed to "invites" page
}
});
}
else if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusAuthorized) {
// The user has previously given access, grab all contacts
// ADD ALL OF USERS CONTACTS TO ARRAY HERE
}
else {
// The user has previously denied access
// Display an alert telling user that they must allow access in order to proceed to "invites" page
}
}

最佳答案

关于ios - 授予地址簿访问权限后,将用户联系人存储在 NSMutable 数组中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21081433/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com