cloudkit

Creating an NSCache for the first time with CloudKit Records - close?

本秂侑毒 提交于 2019-12-04 19:16:46
I have a project I'm close to completing. My last problem arises when I've downloaded CloudKit records to an array to be displayed in a tableview. Here is my code for the query portion of the controller. for result in results! { let tablerestaurant = Restaurant() if let name = result.value(forKey: "Name") as! String? { tablerestaurant.name = name } // Do same for image if let imageAsset = result.object(forKey: "Picture") as! CKAsset? { if let data = try? Data(contentsOf: imageAsset.fileURL) { tablerestaurant.image = UIImage(data: data) } } self.tablerestaurantarray.append(tablerestaurant) //

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

Deleted CloudKit records Reappear

穿精又带淫゛_ 提交于 2019-12-04 18:47:12
问题 I'm building an iOS application using CloudKit. It should allow a user to add, edit and delete Products in the cloud. The user can organize these in Folders. These folders are just other Record Types in cloudkit. There is no limit to the levels of folder the user can use, as any folder can just hold a CKReference to it's parent Folder. All CloudKit communication in my app happens in a dedicated CloudKitController Class This all works, but stops working after a while for no clear reason. When

CKFetchRecordChangesOperation returns no records

耗尽温柔 提交于 2019-12-04 18:36:15
CKFetchRecordChangesOperation in the simplified method below does not return any records. I call it with a nil, to initially get all the records, but it only returns the server token. However, if I use CKQuery I get all the records correctly. What am I missing? func fetchChangedRecords(token :CKServerChangeToken?) { println("\(__FUNCTION__) token: \(token)") let zoneID = CKRecordZoneID(zoneName: kMyZone, ownerName: CKOwnerDefaultName) var op = CKFetchRecordChangesOperation(recordZoneID: zoneID, previousServerChangeToken: token) op.recordChangedBlock = { record in println("\(__FUNCTION__)

iOS swift: Store cache using coredata (cloudkit)

六月ゝ 毕业季﹏ 提交于 2019-12-04 16:11:55
I'm learning to use cloudkit to save and fetch records, but I got confused about saving cache to coredata. For example, I fetched several records and display a few attributes of this record type(say, A, C and F) using a tableview. And when I click a cell, it'll show this record's detail ( all attributes of this record: A B C D E F, but don't including reference attributes record). I was wondering should I store these things into coredata when I fetched the record at the first time: "A C F and recordID" ? And when user click to see detail, I fetch again using recordID? And the key point is what

Saving CloudKit Record “Not Authenticated” (9/1002)“ ”This request requires an authenticated account“”

你。 提交于 2019-12-04 15:59:36
问题 Saving a CKRecord in the simulator gives me the following error: [publicDatabase saveRecord:cloudRouteEntity completionHandler:^(CKRecord *record, NSError *error) { if (error) { NSLog(@"An error occured in %@: %@", NSStringFromSelector(_cmd), error); abort(); } else { dispatch_async(dispatch_get_main_queue(), ^(void) { //gui NSLog(@"Created Cloudkit Entity"); }); } }]; However, it works on the phone. Why does the simulator not have access to the CloudKit database? EDIT: I thought I'd be

How to create user in CloudKit? [closed]

心不动则不痛 提交于 2019-12-04 15:52:05
In Parse, to make a new user, I used: var user = PFUser() user.username = "myUsername" user.password = "myPassword" user.email = "email@example.com" What's the code used in CloudKit to create a new user and use it for login? I had to do something similar recently. I had to create a CKRecord for each user that contained the user's username and password. I added their username to NSUserDefaults to make it easy to retrieve. Here is the code for signing up: //Check if users exist let query = CKQuery(recordType: "MyUsers", predicate: NSPredicate(format: "TRUEPREDICATE", argumentArray: nil)) pubDB

CloudKit: Preventing Duplicate Records

南笙酒味 提交于 2019-12-04 14:03:07
I am working through an app that pulls data from an external web service into a private CloudKit database. The app is a single user app, however I am running into a race condition that I am not sure how to avoid. Every record in my external data has a unique identifier that I map to my CKRecord instances. The general app startup flow is: Fetch current CKRecords for the relevant record type. Fetch external records. For every external record, if it doesn't exist in CloudKit, create it via batch create (modification operation). Now, the issue is, if this process is kicked off on two of a user's

Deleting data from cloudkit with swift

允我心安 提交于 2019-12-04 13:29:24
问题 How do I delete some data I put into the cloud? I made an app that when you enter a url in 1 view controller it uploads into the cloud, and when you go to another view controller it shows the url you entered before from the cloud in a webview. for example, when you enter www.hello.com, it goes into the cloud, and when you go to the webview on a different view controller it loads www.hello.com. My problem: When I enter a second url, it still loads the first one. How do I get it to load the

cloudkit error no authToken received for asset

独自空忆成欢 提交于 2019-12-04 12:09:28
Why do I get this error when I run the following code? : "Internal Error" (1/1000); "No authToken received for asset" I think it has something to do with the setObject code in the last line. let documentsDirectoryPath:NSString = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as NSString var imageURL: URL! let imageData = UIImageJPEGRepresentation(self.newImage, 1.0) let path:String = documentsDirectoryPath.appendingPathComponent(self.newImage.description) try? UIImageJPEGRepresentation(self.newImage, 1.0)!.write(to: URL(fileURLWithPath: path), options: [