CNContactStoreDidChangeNotification多次

时间:2016-10-02 21:28:55

标签: ios swift contacts

每当我的iphone设备的联系人列表发生任何变化时,我都会尝试在我的应用程序中收到通知。 这是我为注册通知程序而编写的代码:

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

func contactChanged(notification : NSNotification){
        print("contact changed notification received")
        var userInfo: NSDictionary!
        userInfo = notification.userInfo
        print(userInfo.allKeys.debugDescription)
}

我的方法" contactChanged"当应用程序从后台返回并且地址簿已更改时,会被调用两次或三次。此外,没有关于地址簿中的变化的信息。你能建议如何制作一次仅通知的通知器吗?并了解变化?感谢

0 个答案:

没有答案