This code worked OK on iOS 5.1 and also does work in the iPhone simulator with iOS 6. It fails silently on my iPhone 4 running iOS 6. The end result is that I cannot add a per
If you got here from Google and you're using iOS's new CNContactStore
framework, and getting these errors, read on:
I thought it'd be cleaner to make my CNContactStore a member variable that was initialized with the class instance:
class foo {
var contactStore = CNContactStore()
func findByIdentifier(identifier: String) -> CNContact {
let contact = try self.contactStore.unifiedContactWithIdentifier(identifier...
return contact
}
}
After I called this about fifty times, it started erroring out with
AB: Could not compile statement for query (ABCCopyArrayOfAllInstancesOfClassInSourceMatchingProperties)
I tried rate-limiting my calls, but that didn't help. It turned out that instantiating a new CNContactStore for every call had zero performance ramifications and completely solved the problem for me:
class foo {
func findByIdentifier(identifier: String) -> CNContact {
let contactStore = CNContactStore()
let contact = try contactStore.unifiedContactWithIdentifier(identifier...
return contact
}
}
Hope this helps!