Reputation: 838
I am trying to make an array of ObjectId's and Int in my parse database. I have the following in my code, but getting an "Error: type() does not conform to protocol 'AnyObject'".
var bN:Array<String> = []
var bb:Array<Int> = []
@IBAction func myBtn (sender: AnyObject) {
var userPost = PFObject(className:”UserPost")
// Object ID of user's post
userPost.objectId = dObjectId
println(“User objectId is \(dObjectId)")
let userOId:NSString = PFUser.currentUser().objectId
println(userOId) // Gives the current user ObjectId
let userB = myB.text.toInt()!
println(userB)
userPost[“myB"] = bN.append("\(userOId)") // Here is where I get the first error: type() does not conform to protocol AnyObject
userPost[“myC"] = bb.append("\(userB)") // Here is where I get the second error: type() does not conform to protocol AnyObject
userPost.saveInBackgroundWithBlock {
(success: Bool, error: NSError!) -> Void in
if (success) {
// The object has been saved.
println("Saved")
self.displayAlert("Saved!", error: "")
} else {
// There was a problem, check error.description
println("Error")
} }
Thanks in advance.
Upvotes: 0
Views: 405
Reputation: 2073
You need to explicitly cast the attribute you are retrieving:
userPost[“myB"] = bN.append("\(userOId)”) as String
Upvotes: 0