ckrecord

CloudKit error handling - retry logic

穿精又带淫゛_ 提交于 2019-12-05 02:43:32
问题 I want to put excellent CloudKit error handling in my app as Apple wants us to do. I want to save and modify a record right now. Here is my basic save logic... func addNewRecord(managedObj: NSManagedObject) { let newRec = managedObj.convertToCkRecord() publicDB.saveRecord(newRec, completionHandler: saveHandler) } func saveHandler(savedRecord: CKRecord?, error: NSError?) { // handle errors here if let error = error { if error.code == CKErrorCode.NotAuthenticated.rawValue { // debug print("Not

How to modify CloudKit Reference Lists

依然范特西╮ 提交于 2019-12-04 19:12:55
I can modify the Reference List attribute of my CKRecord in the dashboard without problems, but how can I modify it programmatically? I currently try modifying it as a NSArray. It does not give me any sort of error but even though the array content is fine, the attribute does not get set. Also the documentation on reference lists is either well-hidden or non-existent. CKReference *reference = [[CKReference alloc] initWithRecord:connectionRecord action:CKReferenceActionNone]; NSMutableArray *list_a = [record_a[@"connections"] mutableCopy]; if (!list_a) list_a = [NSMutableArray array]; [list_a

Stack overflow when defining subscript on CKRecord in Swift

☆樱花仙子☆ 提交于 2019-12-04 03:17:47
问题 This question asks whether one can use subscripting with CKRecord in Swift. While I already knew how to do what the questioner wanted, every permutation of it gives me a stack overflow: subscript(key: String) -> CKRecordValue? { get { return objectForKey(key) as CKRecordValue? } set { setObject(newValue, forKey: key) } } The stack overflow occurs in the getter. (I've never tried the setter, so it may occur there, too.) I've tried implementing with objectForKey: , objectForKeyedSubscript: ,

CloudKit error handling - retry logic

旧街凉风 提交于 2019-12-03 20:21:52
I want to put excellent CloudKit error handling in my app as Apple wants us to do. I want to save and modify a record right now. Here is my basic save logic... func addNewRecord(managedObj: NSManagedObject) { let newRec = managedObj.convertToCkRecord() publicDB.saveRecord(newRec, completionHandler: saveHandler) } func saveHandler(savedRecord: CKRecord?, error: NSError?) { // handle errors here if let error = error { if error.code == CKErrorCode.NotAuthenticated.rawValue { // debug print("Not authentricated") } else if error.code == CKErrorCode.NetworkFailure.rawValue { print("Network failure!!

How to query CloudKit for recordID IN [CKRecordID]

為{幸葍}努か 提交于 2019-12-03 03:04:24
My predicate wants to exclude some records that are already downloaded and available in a [CKRecordID]. Now I can query 1 CKRecordID[0], but not the [CKRecordID] array. How can I query the array? let excludeIDs: [CKRecordID] This works: let pred1 = NSPredicate(format: "NOT(recordID = %@)", excludeIDs[0]) But this doesn't: let pred1 = NSPredicate(format: "NOT(recordID IN %@)", excludeIDs) ERROR: loadImageCompareRecordIDsAndEndDateThatHaveNotEnded Error: Invalid predicate: Invalid predicate: Array members must conform to CKRecordValue: ( "", "", "", "", "" ) (CKRecordID) The other general parts

Stack overflow when defining subscript on CKRecord in Swift

我是研究僧i 提交于 2019-12-01 17:53:58
This question asks whether one can use subscripting with CKRecord in Swift. While I already knew how to do what the questioner wanted, every permutation of it gives me a stack overflow: subscript(key: String) -> CKRecordValue? { get { return objectForKey(key) as CKRecordValue? } set { setObject(newValue, forKey: key) } } The stack overflow occurs in the getter. (I've never tried the setter, so it may occur there, too.) I've tried implementing with objectForKey: , objectForKeyedSubscript: , and valueForKey: . All produce the same result: a stack overflow. This is very strange, since CKRecord is

How to update data in TableView without the delay using CloudKit when Creating new Records

ぐ巨炮叔叔 提交于 2019-11-28 01:14:01
There are 2 View Controllers in my App. The first "MainViewController" displays a tableView with CKRecords fields fetched from the private CloudKit database. Inside the viewWillAppear method of this VC I fetch records from CloudKit and reload data of a tableview to show the latest fetched results that have been previously saved in the CloudKit by the user. The second view controller "CreateRecordViewController" is made for creating CKRecords and saving them to the private database of the CloudKit. So i create records in the CreateRecordViewController and show them in the MainViewController.

How to update data in TableView without the delay using CloudKit when Creating new Records

六月ゝ 毕业季﹏ 提交于 2019-11-26 21:52:06
问题 There are 2 View Controllers in my App. The first "MainViewController" displays a tableView with CKRecords fields fetched from the private CloudKit database. Inside the viewWillAppear method of this VC I fetch records from CloudKit and reload data of a tableview to show the latest fetched results that have been previously saved in the CloudKit by the user. The second view controller "CreateRecordViewController" is made for creating CKRecords and saving them to the private database of the