CloudKit仪表板未更新 [英] CloudKit Dashboard not updating

查看:101
本文介绍了CloudKit仪表板未更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个应用程序,用于存储每个用户的评论,然后将其显示在我的应用程序中。 (就像餐馆评分应用一样)但是,当用户输入评论并点击提交时,仪表板上似乎什么也没有出现。

I'm making an app to store every users' comments and then dısplay them in my app. (just like a restaurant rating app) However when a user enters a comment and hits submit, nothing seems to appear on dashboard.

每种记录类型都设置为可查询我单击查询结果,这给了我应该将索引设置为可查询的错误。

Every record type is set to queryable yet when I click on query results it gives me the error that I should set my indexes to queryable.

这是我的代码。(迅速)

Here is my code.(Swift)

@IBAction func OnSubmitTouched(_ sender: UIButton) {
    if (textField.text != ""){

        let newComment = CKRecord(recordType: "Comment")
        let publicDB = CKContainer.default().publicCloudDatabase
        newComment.setValue(textField.text!, forKey: "comment")
        CKContainer.default().fetchUserRecordID { recordID, error in
            guard let recordID = recordID, error == nil else {
                // error handling magic
                return
            }

            //let userID = CKContainer fetchUserRecordIDWithCompletionHandler:
            publicDB.save(newComment){
                rec ,err in
                if let error = err {

                    print(err.debugDescription)
                    return
                }

                publicDB.fetch(withRecordID: recordID) { record, error in
                    guard let record = record, error == nil else {
                        // show off your error handling skills
                        print(rec!["comment"]!)
                        return
                    }
                    print("The user record is: \(record)")
                }
            }
        }

        let predicate = NSPredicate(value: true)
        let query = CKQuery(recordType: "Comment", predicate: predicate)
        let operation = CKQueryOperation(query: query)

        var commentRecords: [CKRecord] = []

        operation.recordFetchedBlock = { record in
            commentRecords.append(record)
        }

        operation.queryCompletionBlock = { cursor, error in
            print(commentRecords)
        }

        CKContainer.default().publicCloudDatabase.add(operation)


推荐答案

嗯... CloudKit很好地告诉您保存失败的时间。您的任何错误都返回了什么吗?

Hmm... CloudKit is pretty good about telling you when a save failed. Are any of your errors returning anything?

此外, CKContainer.default()是否返回与您正在查看的容器相同的容器ID仪表板?

Also, does CKContainer.default() return the same container ID as the one you're looking at in the dashboard?

我要检查的最后一件事是,您是否在iOS设备和CloudKit仪表板上使用了相同的Apple ID,以便查看同一用户的数据?

The last thing I'd check is are you using the same Apple ID on the iOS device and the CloudKit dashboard so that you're looking at the same user's data?

这篇关于CloudKit仪表板未更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆