How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask Pete Your Own Question

Pete
Pete, Computer Engineer
Category: Programming
Satisfied Customers: 15766
Experience:  Over 16 years of experience in computer programming.
30970729
Type Your Programming Question Here...
Pete is online now
A new question is answered every 9 seconds

Swift Code using CloudKit and Xcode Getting an error message

Customer Question

Swift Code using CloudKit and Xcode
Getting an error message on line "let newBug = Bug()" saying Unresolved identifier "Bug"
import UIKit
import CloudKit
class ViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let container = CKContainer.defaultContainer()
let publicData = container.publicCloudDatabase
let query = CKQuery(recordType: "Bug", predicate: NSPredicate(format: "TRUEPREDICATE", argumentArray: nil))
publicData.performQuery(query, inZoneWithID: nil) { results, error in
if error == nil { // There is no error
for bug in results {
let newBug = Bug()
newBug.title = bug["Title"] as! String
newBug.description = bug["Description"] as! String
self.objects.append(newBug)
dispatch_async(dispatch_get_main_queue(), { () -> Void in
self.tableView.reloadData()
})
}
}
else {
println(error)
}
}
func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
}
Submitted: 1 year ago.
Category: Programming
Expert:  Pete replied 1 year ago.
Hello,
I am Pete, and I'll be happy to assist with your question today.
The only problem I can see is you are using both 'bug' and 'Bug' - try using the same case for all instances and let me know if that resolves the issue.