<分区>
我想在 iPhone 的联系人有插入/更新事件时得到通知。
是否可以向我的应用发送有关发生特定联系人更改事件的通知?
对于 IOS Swift 来说只是一个新手...
我不期待完整的源代码。只是想知道它是否可能并提示。
提前致谢。
<分区>
我想在 iPhone 的联系人有插入/更新事件时得到通知。
是否可以向我的应用发送有关发生特定联系人更改事件的通知?
对于 IOS Swift 来说只是一个新手...
我不期待完整的源代码。只是想知道它是否可能并提示。
提前致谢。
最佳答案
从 iOS 9 开始,您可以注册您的类(class)以观察CNContactStoreDidChangeNotification
NSNotificationCenter.defaultCenter().addObserver(
self,
selector: #selector(addressBookDidChange),
name: NSNotification.Name.CNContactStoreDidChange,
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.
编辑:
请注意,地址簿和地址簿 UI 框架现已弃用。
关于ios - 如何在 IOS 中的联系人更改事件中得到通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29208605/