ArchonLight ArchonLight - 5 months ago 27
Swift Question

Swift ! does not remove Optional()

Before, I have successfully added a ! to force an unwrap to remove the "Optional()" from a variable. I am unable to do this in data returned from Parse.com

query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]!, error: NSError!) -> Void in
if error == nil {

for object in objects {
println(object[myObject]!)
}

} else {
println("Error: \(error) \(error.userInfo!)")
}

}


In the example above, the entire table from the Parse.com class is returned and printed to the console. However,


Optional(...)


is returned for each line even though I force an unwrap using ! at the end

What am I missing?

(Note: myObject is the name of the Column in the Parse Class database)

Answer

MirekE was right. It was a nested Optional(Optional()).

to fix I:

println(object[myObject]!!)