Did you ever figure this out an easier way than how Claude31 did it?
Post
Replies
Boosts
Views
Activity
Did you ever figure out how to do this? I would like to also like my iOS app to access a Note in the Notes app on an iOS device.
Hey KMT,
I haven't been able to get answers to my posts. What do I need to do about this?
Daniel
Did you ever figure this out? I'm getting the same error.
Thanks.
Yeah. That's a good idea. I didn't think about that.Ok. I marked your first answer as correct, because that was where you pointed out the problem.
Maybe when it counted short it ran before all the records were saved.
Your print number of records is working now. When I ran it that one time it counted 687 insteaed of 688.
I think my error was in checking the records after the save. The records were there, I just didn't retrieve it all, so it looks like not all are there. When I checked in CloudKit Dashboard, there were more not loaded. I was only looking at the first load before I loaded more.By the way, your print number of records code was short one. I wonder if you forgot to count the last run of the getChunk.
That still doesn't fix the problem that the records don't get saved. When I query the database later, there still is not 688 records saved like it appears to have saved when I perform the CKModifyRecordsOperation. I actually checkd in CloudKit Dashboard. There really are 32 records only.
I don't follow. Would you show me in my code what you mean?
I think you are working on the problem that the printNumberOfRecords() method is printing the wrong number of records. That's not the problem I'm concerned with. I am concerned that the records are not deleted.
Do you mean by 'completionBlock' the completion closure of the privateDatabase.perform(_:_:) method?
Ok. Thank you very much.
Here's what code I have now: let defaultFileManager: FileManager = FileManager.default
let standardUserDefaults = UserDefaults.standard
let ubiquityIdentityToken = defaultFileManager.ubiquityIdentityToken
let oldDataUbiquityIdentityToken = standardUserDefaults.data(forKey: UserDefaultsKeys.ubiquityIdentityToken)
do {
// Save ubiquity identity token
let dataUbiquityIdentityToken: Data = try NSKeyedArchiver.archivedData(withRootObject: ubiquityIdentityToken!, requiringSecureCoding: false)
standardUserDefaults.set(dataUbiquityIdentityToken, forKey: UserDefaultsKeys.ubiquityIdentityToken)
let oldUbiquityIdentityToken = try NSKeyedUnarchiver.unarchivedObject(ofClass: (NSCoding & NSCopying & NSObjectProtocol).self, from: oldDataUbiquityIdentityToken!)
} catch {
print(error)
}Here are the red code-time errors that appear on the line below the comments in the code:'NSCoding & NSCopying & NSObjectProtocol' cannot be used as a type conforming to protocol 'NSCoding' because 'NSCoding' has static requirementsStatic method 'unarchivedObject(ofClass:from:)' requires that 'NSCoding & NSCopying & NSObjectProtocol' inherit from 'NSObject'I get the argument I put in for the 'forClass' parameter from the declaration of FileManager.ubiquityIdentityToken in Apple's documentation, which says:@NSCopying var ubiquityIdentityToken: (NSCoding & NSCopying & NSObjectProtocol)? { get }What threw me off at the beginning is the fact that the errors appear before I even put in the arguments in the placeholders.