I'm writing an app that stores contact-info fetched through REST and JSON into a container, using CNContactStore. I would like to keep these contacts separate from any other accounts, and only stored locally on the device, but a local store doesn't exist, and I can't find any way to create/activate one?
I'm able to get the default store's ID (as configured on the device, e.g. iCloud), using:
let store = CNContactStore()
let containerID = store.defaultContainerIdentifier()
...and I can (theoretically) identify a local container like this — if one actually exists:
var allContainers = [CNContainer]()
do {
allContainers = try store.containersMatchingPredicate(nil)
for container in allContainers {
if container.type == CNContainerType.Local {
print("Local container is: \(container.identifier)")
break
}
}
} catch {
print("Error fetching containers")
}
But no local container exists. Any ideas on how to store my contacts locally, or in a new separate container?