I'm newer to Swift and I'm trying to get data from the currentUser in my Parse Database, but I am getting an error after I updated to Xcode 6.3. I have made a function called currentUserInfo and I am querying the data from my User class in the parse cloud. The error says: Cannot invoke 'findObjectsInBackgroundWithBlock' with an argument list type '(([AnyObject]!, NSError!) -> Void'
func currentUserInfo () {
var query = PFUser.query()
query!.whereKey("objectId", equalTo: PFUser.currentUser()!.objectId!)
query!.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]!, error: NSError!) -> Void in
if error == nil {
let user = PFUser.currentUser()
var firstname = user["fbUsername"] as! String
var email = user["email"] as! String
var facebookId = user["fbId"] as! String
}
}
}
Also I was able to avoid this error by changing
(objects: [AnyObject]!, error: NSError!)
to
(objects: [AnyObject]?, error: NSError?)
But when I did this it gave me errors on each of these lines:
var firstname = user["fbUsername"] as! String
var email = user["email"] as! String
var facebookId = user["fbId"] as! String
Error: 'AnyObject?' is not convertible to 'String'
How can I get this up and running?