I'm building an iOS app using Swift and Parse. I have a simple data table with three keys. I'm trying to use a Parse query in viewDidAppear to access each element in the table. I'm trying to println() the elements for now, and then later would like to append them to a [String] array.
Here's what I've tried:
var query = PFQuery(className: "BCCalendar")
query.findObjectsInBackgroundWithBlock {(objects: [AnyObject]!, error: NSError!) -> Void in
if error == nil {
for object in objects {
var event = object["events"] as String
var date = object["dates"] as String
var formattedDate = object["formattedDates"] as String
println("Event \(event) is on \(date) which is formatted as \(formattedDate)")
}
} else {
// Do something
}
}
Every time I run the code, the app crashes with the error: Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1008564b0). I've tried multiple methods to query from Parse. I've made sure the table has elements in it. But, I still have the same problem. Any ideas? Thanks!
More details on the crash: It crashes on this line: var event = object["events"] as String. I've added a breakpoint and it does reach the for loop. The object does contain the right elements (I was able to print it somehow before).
object["events"] as [String]if your events is an array of strings