Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Saveddata: [CKRecord] = []
- @IBAction func getAlbum(_ sender: AnyObject) {
- let Container = CKContainer.default()
- let database = Container.publicCloudDatabase
- let predicate = NSPredicate(value: true)
- let query = CKQuery(recordType: "Photos", predicate: predicate)
- database.perform(query, inZoneWith: nil) { //A
- records, error in
- if error != nil { //B
- print(error?.localizedDescription ?? 10)
- } // B
- else { //C
- count = (records?.count)!
- print("countttttt (count)")
- for myrecord in records! { //D
- self.Saveddata.append(myrecord as CKRecord)
- } //D
- let Queue = OperationQueue.main
- Queue.addOperation() { //E
- self.tableview.reloadData()
- } //E
- } //C
- } //A
- } //G
- }
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let ckRecord = Saveddata[indexPath.row]
- //ERROR appears when executing below line////////
- let name = ckRecord.object(forKey: "code") as! String
- cell.textLabel!.text = name
- return cell
- }
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return self.Saveddata.count
- }
Add Comment
Please, Sign In to add comment