gpt4 book ai didi

iphone - 如何在 iOS 的地址簿中检查和检索更改/新添加的联系人详细信息?

转载 作者:太空狗 更新时间:2023-10-30 03:43:08 26 4
gpt4 key购买 nike

在我的应用程序中,我正在获取所有地址簿数据。但是当我下次启动应用程序时,我只想检索地址簿中修改/新添加的联系人。

你能给我一些可能的方法吗?

谢谢。

最佳答案

从 iOS 9 你可以注册你的类来观察 CNContactStoreDidChangeNotification:

Obj-C 代码:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addressBookDidChange:) name:CNContactStoreDidChangeNotification object:nil];

然后:

-(void)addressBookDidChange:(NSNotification*)notification
{
//Handle event here...
}

Swift代码:

NSNotificationCenter.defaultCenter().addObserver(
self,
selector: "addressBookDidChange:",
name: CNContactStoreDidChangeNotification,
object: nil)

然后:

@objc func addressBookDidChange(notification: NSNotification){     
//Handle event here...
}

Contacts Framework Reference 中所报告

After a save is successfully executed, the contact store posts a CNContactStoreDidChangeNotification notification to the default notification center. If you cache any Contacts framework objects you need to refetch those objects, either by their identifiers, or with the predicates that were used to originally fetch them, and then release the cached objects. Note that cached objects are stale, but not invalid.

关于iphone - 如何在 iOS 的地址簿中检查和检索更改/新添加的联系人详细信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8525012/

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