iOS 9 CloudKit:查询在连接到蜂窝网络时不返回任何内容 [英] iOS 9 CloudKit: query does not return anything while connected to cellular network

查看:89
本文介绍了iOS 9 CloudKit:查询在连接到蜂窝网络时不返回任何内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个带有xcode 7 beta 5的应用程序。当我在iphone 6上运行我的应用程序时,如果我的iphone在wifi模式下工作,我尝试将它连接到CloudKit,所有这些都可以,我显示所有数据;但如果我的iphone在LTE模式下工作,我看不到任何类型的数据。有谁知道怎么做?

I'm developing an app with xcode 7 beta 5. When i run my app on my iphone 6 and i try to connect it to CloudKit if my iphone works in wifi mode all it's ok, i display all my data; but if my iphone works in LTE mode i can't see any kind of data. Does anyone know how to do this?

    func getRecordsFromCloud() {  

    lavori = []  

    /  

    let _cloudContainer = CKContainer.defaultContainer()  
    let publicDatabase = CKContainer.defaultContainer().publicCloudDatabase  

    /  

    let predicate = NSPredicate(value: true)  
    let query = CKQuery(recordType: "Lavori", predicate: predicate)  

    /  

    let queryOperation = CKQueryOperation(query: query)  

    queryOperation.desiredKeys = ["image","name"]  
    queryOperation.queuePriority = .VeryHigh  
    queryOperation.resultsLimit = 50  

    queryOperation.recordFetchedBlock = { (record:CKRecord) -> Void in  

        let lavoriRecord = record  

        self.lavori.append(lavoriRecord)  



    }  

    queryOperation.queryCompletionBlock = { (cursor:CKQueryCursor?, error:NSError?) -> Void in  

        if (error != nil) {  

            print("Failed to get data from iCloud - \(error!.localizedDescription)")  

        }  
        else {  

            print("Successfully retrieve the data from iCloud")  

            dispatch_async(dispatch_get_main_queue(), {  
                self.tableView.reloadData()  

            })  

        }  

    }  

    /  

    publicDatabase.addOperation(queryOperation)  

}  

谢谢,Alessio

Thanks, Alessio

推荐答案

打开设置应用,找到你的应用,启用'使用移动数据'

Open the settings app, find your app, enable 'use mobile data'

更新:如下所述
添加以下代码行解决了问题:

Update: As discussed below Adding the following line of code solved the problem:

queryOperation.qualityOfService = .UserInteractive

之所以必须如此iming / load问题。我最初的猜测是这是由这一行引起的:

The reason why this works must be a timing / load issue. My initial guess would be that this is caused by this line:

queryOperation.queuePriority = .VeryHigh

文件显示 .queuePriority 这个:
你应该仅根据需要使用优先级值来对非依赖操作的相对优先级进行分类。

The documentations states for the .queuePriority this: You should use priority values only as needed to classify the relative priority of non-dependent operations.

.qualityOfService this:
此属性的默认值为NSOperationQualityOfServiceBackground,您应尽可能保留该值。

The documentation states for the .qualityOfService this: The default value of this property is NSOperationQualityOfServiceBackground and you should leave that value in place whenever possible.

所以请尝试删除 .queuePriority .qualityOfService 并查看它是否正常工作。

So please try removing both the .queuePriority and .qualityOfService and see if it's working.

更新2:显然这是一个CloudKit错误。更多人有同样的问题。请通过 https://bugreport.apple.com 报告

Update 2: Apparently this is a CloudKit bug. More people have the same issue. Please report it at https://bugreport.apple.com

这篇关于iOS 9 CloudKit:查询在连接到蜂窝网络时不返回任何内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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