Reputation: 707
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)
Upvotes: 12
Views: 12503
Reputation: 21
You only have to put "!" at the end of your variable, in print area
self.addressLabel.text = "\(subThoroughfare) \(p.thoroughfare!) \n \(p.subLocality!) \n \(p.subAdministrativeArea!) \n)".
Upvotes: 2
Reputation: 707
MirekE was right. It was a nested Optional(Optional()).
to fix I:
println(object[myObject]!!)
Upvotes: 16