FAQ Database Discussion Community


Core Data with CloudKit

ios,core-data,cloudkit
When using Core Data with CloudKit, does the iCloud container (ubiquity container) containing the copy of sqlite db still exist at local device?

Possible to set default CloudKit container not based on application name?

ios,cloudkit
When I turn on CloudKit in Xcode, it set and create a default container based on the name of the app. Is it possible to set a different default name? I do not want to see a new container name on the list in CloudKit dashboard, but use an existing...

CKAsset won't show in tableview image

ios,uitableview,swift,uiimage,cloudkit
I have an optional image in the cloudkit DB(checked DB and the image is there in cases where I added it in my testing). I have created a class that initializes the record fields into variables I use in my tableview. I have a custom cell as well. But the...

“Asset File Not Found” (16/3002); “Can't read the file”

ios,cloudkit
I want so save an CKAsset and I get back this error: Asset File Not Found" (16/3002); "Can't read the file Any idea?...

CloudKit. Problems with subscriptions

ios8,cloudkit,cksubscription
I do not quite understand the information about subscriptions. I have Private Database. There is a table to which I create a subscription. If I subscribe to two devices under one iCloud account, errors occur: Subscribed with error: CKError 0x165c6ac0: "Server Rejected Request" (15/2032); server message = "subscription is duplicate...

How can I speed up performQuery in Swift?

swift,cloudkit
So I am creating this app that uses CloudKit to save and fetch images and text from the Cloud. The problem is that I can only access the results after the whole fetch is done. I would like to be able to fetch each record individually as it is fetched....

How to keep data from iCloud(CloudKit) loaded after switching view controllers

swift,core-data,icloud,cloudkit,ckquery
I am in the process of making an app using CloudKit, but I have recently run into a problem. In my app, as soon as the main view controller loads, it goes off and fetches data from iCloud. The problem is that when I segue to another view controller and...

CloudKit CKRecordZone

ios,cloudkit
I have been fiddling with CloudKit for some time now, but I can't find a real-life example for how to use CKRecordZone. I understand their capabilities (namely, grouping records, especially for subscriptions), but does someone have a real experience of having used them, and to map which concept ? Thanks...

When CloudKit error occurs should client keep resending?

ios,recursion,cloudkit
When client get a CKErrorRequestRateLimited client should perform operation again after RequestRateLimited sec. But what do you do when get some different error type i.e. CKErrorZoneBusy. How do you manage that case? I try to resend message recursively in every 10 sec, but it seems it does not help, because...

Why does CloudKit discovery return zero users on a device but multiple in the simulator?

ios,cloudkit
I have the same address book records on both the simulator and the device but when I run the app I get different results... In the Simulator, Number of records returned = 3 On the Device, Number of records returned = 0 Does discovery even work on device in a...

Load CKAssets into UICollectionView async

ios,uicollectionview,cloudkit,ckasset
Is there a way to load CKAsset photo into UICollectionView asynchronously ? At the moment, inside queryCompletionHandler from CKDatabase performQuery, I get list of CKRecords with CKAssets, and then set UICollectionView images to CKAsset.fileURL.path, which I then do [UICollectionView reload] The reload takes a long time because it seems like...

CloudKit fetchRecordWithID error: “Fetching asset failed”

ios,fetch,cloudkit
I am trying to fetch a record with CloudKit and it fails with the following error: "Fetching asset failed" I confirmed (via the CloudKit Dashboard) that the record exists in my public database and the default zone and the default container (not a custom container). Here is my code: CKContainer...

CKFetchRecordsOperation + CKQueryOperations … what am I missing?

ios,objective-c,nsoperation,cloudkit,ckrecord
Managed to cobble together a CKFetchRecordsOperation after much searching for sample code; and here it is... but I must have missed something. Don't get me wrong it works a treat... but... To execute a CKFetchRecordsOperation you need an NSArray of CKRecordIDs; to get a NSArray of CKRecordIDs, you need to...

Copy schema from one container to another

ios,cloudkit
In CloudKit Dashboard, I created Record Types in wrong container (another app). Is there a way to copy or export/import schema to another container (another app)?

Predicate comparing two keys

ios,swift,nspredicate,cloudkit
I am trying to write a predicate to compare two keys in a cloud kit database. All the documentation I've been able to find only allows you to compare one key against a set value. Is there a way to write a predicate in swift to compare two keys? The...

CKAccountStatus returning different values when not called from ViewController

ios,objective-c,cloudkit
I'm using Cloud Kit in my app which makes use of the camera and only allows the user to submit photos if they're logged into iCloud. So when the user clicks the camera button, I call a CloudKit method to get the user's icloud status, which returns a CKAccountStatus value...

iOS Swift: Crash on deleteRowsAtIndexPaths

ios,swift,uikit,icloud,cloudkit
I'm getting a crash when I remove a row from a tableView. Not sure what's going on. Here is my code: func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) { let items = days[indexPath.row] self.removeItems(items, indexPath: indexPath) } func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return days.count...

Full CoreData uploading (backup) to iCloud Drive and restore if need

ios,xcode,core-data,icloud,cloudkit
My project is CoreData-based application. Is it enough to upload sqlite-file to CloudDrive for restoring data when need? Is there any tutorials how to implement it?

CloudKit Unexpected Expression for NSPredicate

ios,cloudkit
I'm using CloudKit and wish to perform a search for records based on their string fields. Apple docs say this is the way to do a tokenized search of a record's fields: To perform a tokenized search of a record’s fields, use the special operator self. A tokenized search searches...

CloudKit ___recordID is not marked queryable

objective-c,xcode,swift,cloudkit
I tried to save data to the CloudKit programmatically with success but I got an error when I fetch data from CloudKit I got an error > <CKError 0x608000052060: "Invalid Arguments" (12/2015); server message > = "Field '___recordID' is not marked queryable"; uuid = 19F1E556-5384-42FD-8F65-9FD8A9C9523D; container ID = > "iCloud.com.mywebsite.CloudDemo">...

cloudkit enter userID as reference of a new record (in code)

swift,cloudkit,ckreference
I am setting an app in which a user could create records. Let's say he/she is the owner of a chatroom. Therefore there is an attribute called "admin" in the chatroom record. This attribute takes a reference which is the ID of the owner. Here is what I tried: CKContainer.defaultContainer().fetchUserRecordIDWithCompletionHandler({...

Estimating and measuring CloudKit database usage

icloud,cloudkit
CloudKit has some pretty stringent data limits, restricting to 50MB of database storage plus 1MB per user, with 250KB/day in database bandwidth plus 5KB per user. To find out how CloudKit incorporates database structure and protocol overheads into these numbers, is there a dashboard I'm able to look at to...

discoverAllContactUserInfosWithCompletionHandler faster?

ios,objective-c,cloudkit
How can I create a CKOperation with higher priority than the default for discoverAllContactUserInfosWithCompletionHandler? I can't find an example of querying all user info without using [[CKContainer defaultContainer] discoverAllContactUserInfosWithCompletionHandler: which is pretty low priority and takes forever to complete....

cloudkit: how to access main user's attributes?

swift,user,nsuserdefaults,cloudkit
I am fairly new to programing and a total newbie regarding cloudkit. I am trying to make an app in which every user would have a personal avatar, a nickname and so on. The problem is that I don't know how to access the user's account on cloudkit. My solution...

CloudKit: Fetch all records with a certain record type?

ios,sdk,icloud,cloudkit,ckrecord
I have currently got CloudKit set up in my app so that I am adding a new record using the help of the following code below, CKRecordID *recordID = [[CKRecordID alloc] initWithRecordName:@"stringArray"]; CKRecord *record = [[CKRecord alloc] initWithRecordType:@"Strings" recordID:recordID]; [record setObject:[NSArray arrayWithObjects:@"one", @"two", @"three", @"four", nil] forKey:@"stringArray"]; [_privateDatabase saveRecord:record completionHandler:nil];...

Move record from development to production in CloudKit?

ios,cloudkit
I have plenty of record manually preloaded to CloudKit but in the development environment. When I deployed development environment, records were not moved into production environment. It is really annoying. Any easy way to move records?...

Xamarin developed app using CloudKit is still cross-platform?

ios,xamarin,cloudkit,multiplatform
Read here an article how CloudKit can be accessed / used from Xamarin. Does it mean Android version still able to access / store data in CloudKit?

Ensembles with directories in CloudKit

core-data,sync,cloudkit,ensembles
I'm using Ensembles in this project where I have different user-groups stored under separate directories. I've built this more or less copying the example app, Idiomatic's sync-manager. Initialising the CDECloudFileSystem i do this: newSystem = [[CDECloudKitFileSystem alloc] initWithUbiquityContainerIdentifier:[CKContainer defaultContainer].containerIdentifier rootDirectory:directoryString usePublicDatabase:YES]; Where the directoryString is the global ID of the...

“Couldn't send a valid signature” error when using CloudKit

objective-c,cloudkit
Anyone know what could be causing this error which is returned in the query block below: <CKError 0x7f8d5ba27a10: "Internal Error" (1/4000); "Couldn't send a valid signature"> Here is my code snippet: CKContainer *container = [CKContainer defaultContainer]; CKDatabase *publicDatabase = [container publicCloudDatabase]; //CKDatabase *publicDatabase = [[CKContainer containerWithIdentifier:container] publicCloudDatabase]; NSPredicate *predicate =...

Reloading CloudKit data when app comes to foreground

ios,swift,ios8,cloudkit
I'm trying to understand CloudKit, but I'm having an issue figuring out a real-world issue if I eventually turned it into an app. I've got a tableviewcontroller that's populated by CloudKit, which works fine. I've got a detailviewcontroller that is pushed when you tap one of the entries in the...

Any drawback if CKRecordID.recordName is generated on client?

ios,cloudkit,ckrecord
It could provide a more smooth user experience if recordName is generated on client. var uuid = NSUUID().UUIDString Do you know any disadvantage to do it?...

Hide UIProgressView when animation is completed

ios,swift,animation,cloudkit,uiprogressview
I am saving array of records in cloud kit with CKOperation as follows & displaying progress with progress view. let saveOperation = CKModifyRecordsOperation(recordsToSave: ckRecord, recordIDsToDelete: nil) saveOperation.perRecordProgressBlock = { record, progress in if progress >= 1 { self.completedRecord.addObject(record) let totalSavedRecord = Double(self.completedRecord.count) let totalProgress = totalSavedRecord / self.totalStudent let percentageProgress...

iOS Swift: Sort array into multidimensional array

ios,arrays,swift,icloud,cloudkit
I have an array of CKRecords. Each record has startTime and a Name, among other values. What I would like to do is sort the records first by unique startTime and then within each startTime sort by unique Name. The end result would be an array that looks like this...

How to get recordID of CKReference

objective-c,ios8,cloudkit
I'm using CloudKit and I have two record types. Record type B contains a CKReference to record type A. I'm not having any trouble getting record type B, including the CKReference data of record type A, but I can't figure out how to get the recordID from the CKReference record...

Cast / convert dictionary in Swift

ios,swift,core-data,casting,cloudkit
How can I convert an [NSObject : AnyObject] -> [NSString: CKRecordValue] in Swift? personEdited!.changedValues() as [(NSString, CKRecordValue)] personEdit in a NSManagedObject. ...

CloudKit Error when modifying CKRecords: “Zone Busy”

ios,cloudkit
Here's a snippet of code in which I'm modifying some records on a user's private CloudKit DB. let op = CKModifyRecordsOperation(recordsToSave: recordsToModify, recordIDsToDelete: []) op.savePolicy = CKRecordSavePolicy.ChangedKeys op.modifyRecordsCompletionBlock = { saved, deleted, err in println("modified all ... \(saved.count) w err '\(err)' \(err != nil ? err.userInfo : [:])") } self.privateDB.addOperation(op)...

Creating a User record based on currently logged in Apple ID

ios,objective-c,cloudkit
Using Objective-C is there a way I can create a new user to an app based on their apple ID automatically. I would be using this in conjunction with CloudKit In order to create and auth users without creating a whole 'login' and 'sign up' view

CloudKit: Order query results by creation date

ios,swift,icloud,cloudkit
When loading items from CloudKit I would like to order the results by creation date. I believe now it's sorting by the first property of the record. func loadItems() { let predicate = NSPredicate(value: true) let query = CKQuery(recordType: "Items", predicate: predicate) db.performQuery(query, inZoneWithID: nil) { (results, error) -> Void...

CloudKit (a background process) and UI communication

swift,ios8,cloudkit
I have a login screen. The user enters username and password then clicks login. Then the class connects to database loads the data and returns true or false. However, because the perform query operation is done in a different thread, the Load function always returns false. But the debugging shows...

Query CloudKit database with multiple record types

ios,swift,cloudkit
I have a cloud kit database set up and am trying to query against it. It looks like predicates won't work for what I'm trying to do. In SQL the query would look something like this: SELECT type1 FROM table1, table2 WHERE table1.columnA = table2.columnB Also, similar to: NSPredicate(format: "%K...

Nested CloudKit queries and UITableView

ios,uitableview,swift,cloudkit
I am trying to make a simple table-based app using CloudKit that allows you to drill down to find more information about a particular item. Let's say my app shows a directory of shops located inside theme parks, divided by sections of the park. In my initial table view, I...

Cloudkit , Unrecognized Selector [duplicate]

ios,swift,uicollectionview,cloudkit
This question already has an answer here: How can I debug 'unrecognized selector sent to instance' error 5 answers [CKRecord stringForKey:]: unrecognized selector sent to instance 0x17412ece0' I am getting the above error, and not sure what I need to do to correct it. I am running a query...

Swift / Cloudkit predicate format

swift,nspredicate,cloudkit
I am trying to write a predicate using coordinates stored in a CloudKit database. I am struggling to find any accurate documentation on the way to format it. Here is what I've come up with: NSPredicate(format: "distanceToLocation:fromLocation: (%K,%@) < 1000", "locationcoordinates") I am getting the following error: Terminating app due...

Anyway to check CloudKit app runs as developer or production mode?

ios,cloudkit
In developer mode I want to skip populating local database from bundle, but I need it when apps run in production mode. Any way to check it?

Mocking CKContainer for Unit Testing

ios,unit-testing,swift,ios8,cloudkit
I am using CloudKit in my application and am trying to mock CKContainer to test my Managers. Here is what i tried: func testAccountStatus() { class MockCloudContainer: CKContainer { override func accountStatusWithCompletionHandler(completionHandler: ((CKAccountStatus, NSError!) -> Void)!) { completionHandler(CKAccountStatus.NoAccount, NSError()) } } let loginManager = LoginManager.sharedInstance let expectation = expectationWithDescription("iCloudStatus") var...

cloudkit custom container name

swift,icloud,cloudkit
I've downloaded apple's CloudKitAtlas sample code to learn about cloudkit. To run it I have to change the container name. But I wasn't able to do it so far. I cannot use the default's container. And when I click "specify custom containers" and add one, I always get two errors...

CloudKit push notification subscription not working

ios,swift,cloudkit
I'm trying to subscribe to push notifications using CloudKit. I'm getting this error: <CKError 0x170c5b1e0: "Unknown Item" (11/2003); server message = "could not find required field fieldID="25"" from this code: let subscription = CKSubscription(recordType: "PlayerData", predicate: NSPredicate(format: "TRUEPREDICATE"), options: CKSubscriptionOptions.FiresOnRecordCreation) let notificationInfo = CKNotificationInfo() notificationInfo.shouldBadge = false subscription.notificationInfo = notificationInfo...

Deleting data from cloudkit with swift

xcode,swift,icloud,cloudkit
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...

NSPredicate with OR returning error

ios,nspredicate,cloudkit
I have a problem with the following predicate: NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(creatorUserRecordID == %@) OR (toUser == %@)", userId, userId]; When I use it in query CKQuery *query = [[CKQuery alloc] initWithRecordType:@"Message" predicate:predicate]; I have an error that says: 'CKException', reason: 'Unexpected expression'. When I use these two seperately...

Type anyObject? does not conform to 'StringLiteralConvertible'

ios,arrays,swift,uicollectionview,cloudkit
I am trying to add pictures stored as CKAssets to an array in a collection view, however my query to bring back the images is giving me an error that I can't figure out. Can anyone help me out? My code is: class Query: UIViewController { override func viewDidLoad() {...

performQuery, cannot set inZoneWithID to nil

swift,cloudkit,ckquery
Hi I am trying to make a small function that should send me back the record that corresponds to the user by entering his/her name. I created a swift file: import Foundation import CloudKit import UIKit func getGetMainUser(name : String) -> CKRecord { var myRecord : CKRecord! let container =...

CloudKit subscriptions in the private database

ios,swift,cloudkit,cksubscription
I have an app for which I want to add the possibility to backup data to iCloud using CloudKit. The "backup" part seems to work correctly (my records are in the private database, since they are ... well, private). Now I would like to use CKSubscriptions to keep all my...

NSPredicate case insensitive string search with CloudKit

ios,swift,nspredicate,cloudkit
I'm trying to search a String field of a CloudKit object. The following line successfully compiles and runs without error. NSPredicate(format: "Title BEGINSWITH %@", "Apple") Yet, when I try add case insensitive search, it the app crashes. NSPredicate(format: "Title BEGINSWITH[cdl] %@", "Apple") With error: *** Terminating app due to uncaught...

CloudKit Push Notification, App running on background

ios8,apple-push-notifications,cloudkit,ios8.2
When iOS8.2-app is running in the background, it does not receive any push notification, while if it is running on the foreground, it receives the push notifications fine. Any idea what is going on ? Running on CloudKit Development mode, the subscription is for add,edit,and remove, and using the following...

Some questions about CloudKit

ios,cloudkit
record type: Country(CKRecord) -------------------- name: String code: String -------------------- record type: User(CKRecord) ------------------------ name: String country: CKReference (reference to country record> ------------------------- I have 2 record types (Country and User) created by CloudKit Dashboard. I encountered some cloudkit issues. currently! I query User and then using country reference to fetch...

CloudKit compound query (query with OR)

ios,nspredicate,cloudkit,ckquery
I would like to query CloudKit using OR with two fields. But I can't find a way how to do this. What I did is: NSPredicate *predicate1 = [NSPredicate predicateWithFormat:@"(creatorUserRecordID == %@)", userId]; NSPredicate *predicate2 = [NSPredicate predicateWithFormat:@"(toUser == %@)", userId]; NSCompoundPredicate *compPredicate = [NSCompoundPredicate orPredicateWithSubpredicates:@[predicate1, predicate2]]; CKQuery *query =...

How to organize icloud data by date added?

xcode,swift,icloud,cloudkit
I am making an app that uses cloud-kit, and when I ask it to return the data saved on it, its out of order. How to i organize the data by date? And then save it in an array, with array [0] as the most recent data added? by the...

Failed to load resource: the server responded with a status of 421 (Bad Request)

javascript,html,ios,web-services,cloudkit
I am using Apple's new CloudKit JS reference and sample code to build a simple CRUD app. Before I can even get to CRUD however I am being stopped by Apple authentication. index.html <html> <body> <div id="apple-sign-in-button">Sign in <span id="username"></span> </div> <script> /* * Initialize the global objects we will...

How to delete a CKRecord

ios,swift,cloudkit,ckrecord
How do I delete a CKRecord from my database programmatically, on the client side. for record in records { if recordNumber < 13 { let moodRecord:CKRecord = record as! CKRecord self.moodArray.append(moodRecord.objectForKey("Color") as! String) } else if recordNumber > 13 { // DELETE RECORD HERE record.delete(CKRecord) recordNumber-- } recordNumber++ } ...

Curious whether fileUrl of CKAsset can change with time?

ios,cloudkit,ckasset
I am caching CKRecord on client and fileUrl of CKAsset too. Can fileUrl change from time to time? Asset / data itself is not changing.

Does subscript operator work for CKRecord?

ios,cloudkit,ckrecord
I want to use subscript operator like docs show: myRecord[@"firstName"] = @"Jacob"; but can't get it to work in Swift. Any idea why? ...

Cannot assign userID as reference

swift,icloud,cloudkit,ckreference
I am trying to assign several different attributes to a record. Date & Name are working properly. Avatar, which is a reference to another record, works also fine. But then I try to assign a reference to the user and I get the slamyourheadagainstthescreen moment. Here is my code: var...

Are there issues with an array of CKAssets in a single CKRecord?

ios,cloudkit,ckrecord,ckasset
The app I'm writing will let people store several photos, and associate them with a single object. I thought I would use CloudKit, to store these images, as CKAssets. In CloudKit, besides the other property-list types, I can create a CKAsset, and attach a file to it (in my case,...

Find User Name or First/Last Name in iOS9 CloudKit / ABPerson (ABAddressBook)

abaddressbook,cloudkit,ios9,abperson
iOS9 deprecates user info features for CloudKit and for ABPerson. e.g. in the properties of CKDiscoveredUserInfo firstName" Deprecated in iOS 9.0 lastName" Deprecated in iOS 9.0 I want last name and first name as previously provided in iOS8 CloudKit. How to retrieve the similar information in iOS9 CloudKit, ABPerson or...

Since iOS8 we should use CloudKit for all iCloud apps?

ios,icloud,cloudkit
I've noticed a lot of people creating iCloud apps using Obj-C and importing .h etc. To a noob like me it seems very complex since I've been using Swift from the beginning. People say iCloud apps can be created using only Swift and CloudKit exclusively. Is it possible? Thanks

How to connect CKQueryNotification to a CKRecord or CKSubsription?

ios,cloudkit,cknotification
I need a way to connect a CKQueryNotification to a CKRecord or CKSubscription so I can receive updates/inserts/deletes on multiple record types. I'm successfully receiving CKNotifications and this is the payload: { ck = { ce = 2; cid = "<my cloud container id>"; nid = "<unknown guid>"; qry =...

All CKAsset is available on all device?

ios,cloudkit,ckasset
When I save up a CKAsset to server, will it be available on all device? What if on a certain device I do not need one of the asset? Will it take space there too? ...

Is user able to delete CKSubscriptions from Settings?

ios,cloudkit,cksubscription
I am curious wether user can deny subscriptions after it was accepted?

Appending an array in swift, having problems

ios,arrays,swift,cloudkit
I am getting the error 'AnyObject' does not have a member named 'append' for results that I am trying to post to an array. I'm not sure how to fix the error, as I thought my code was correct. Can someone help me make the proper adjustments? My code is...

Collection View Controller crashing and not returning images

swift,uicollectionview,cloudkit
I am building a Collection View to return images from a CloudKit database. The results are returning slowly, but they are returning. However, I am getting the classic "fatal error: unexpectedly found nil while unwrapping an Optional value" error and I can't figure out why or what I have to...

How to approve uploads to CloudKit

ios,cocoa-touch,icloud,cloudkit
When creating an application that uses CloudKit, sometimes you allow the user to create and upload data to the public database which will be publicly available to everyone once it's created. This leads to my question which is: How do you review/moderate/approve user created data before making it available to...

How to check CKAsset changes with CKSubscription?

ios,cloudkit,cksubscription,ckasset
How do you check whether an image stored with CKAsset has changed in CloudKit? CKNotification doc says about desiredKeys: You can include a maximum of three keys in the array. For the keys you specify, the allowable values are NSString, NSNumber, CLLocation, NSDate, and CKReference. You cannot specify keys whose...

RequestRateLimited in CKQueryOperation

ios,cloudkit
If a CKQueryOperation returns a RequestRateLimited error, should the same queryOperation added to publicDatabase, or should a new queryOperation created based on the cursor received? Does client receive cursor if RequestRateLimited error occurred?

How to fetch list of CKRecordIDs

ios,cloudkit
I'd like to be able to download a list of all CKRecordIDs of a certain record type from a Cloud Kit database. I don't want the records themselves, since they have large assets that aren't needed until the user asks for them. CKQuery seems to return CKRecords only. Any ideas?...

Keep order of NSArray with CloudKit

ios,objective-c,osx,cocoa,cloudkit
I'm currently designing a CloudKit based syncing-solution and I wondered what the best way is to keep the order of a list (an array in my case) of cloud items (CKRecord objects) consistent. Apple advises against holding a reference to child objects and instead just reference the parent object with...

CloudKit: “There is no operation associated with this request”

ios,cloudkit
When attempting to save a CloudKit CKRecord, I get a CKError returned which gives the following description: <CKError 0x7fd3d24e1810: "Internal Error" (1/2005); "there is no operation associated with this request"> Any ideas what might cause this? Google does not return any results at all to this error....