Ich habe einen Datensatztyp - "DiningTypes". "DiningTypes hat nur einen Feldtyp, der eine Zeichenkette ist. Ich habe 5 Einträge ... und es dauert 3-4 Sekunden, um eine Tabelle zu laden. Wie ist das so langsam? Muss ich den Abrufvorgang in einem starten?" vorherige Controller schnelle UI Reaktionszeiten haben?CloudKit - Abrufen von 5 Datensätzen mit einem Feldtyp ... dauert 3-4 Sekunden. Warum ist es so langsam?
import UIKit
import CloudKit
class table1: UITableViewController {
var categories: Array<CKRecord> = []
var fetchedcategories: Array<CKRecord> = []
override func viewDidLoad() {
super.viewDidLoad()
func fetchdiningtypes()
{
let container = CKContainer.defaultContainer()
let publicDatabase = container.publicCloudDatabase
let predicate = NSPredicate(value: true)
let query = CKQuery(recordType: "DiningTypes", predicate: predicate)
publicDatabase.performQuery(query, inZoneWithID: nil) { (results, error) -> Void in
if (error != nil)
{
print("Error" + (error?.localizedDescription)!)
}
else
{
for result in results!
{
self.categories.append(result)
}
}
}
}
fetchdiningtypes()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return categories.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("dining") as! table1cell
let restaurant: CKRecord = categories[indexPath.row]
cell.Name.text = restaurant.valueForKey("Name") as? String
return cell
}
}
I'v häufig h Die Entwicklung des Kommentars ist weit langsamer als die Produktion, wenn Sie Ihren Code so effizient wie möglich gemacht haben, mehr können Sie nicht tun. – user3069232
Haben Sie das in einer Online-Publikation gesehen? Es klingt vielversprechend. –