0
votes

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.

1
Whats with the ?tskulbru
@tskulbru Copy paste created some problem. Sorry, edited. Now can you help removing the error?NS1518

1 Answers

0
votes

You need to explicitly cast the attribute you are retrieving:

userPost[“myB"] = bN.append("\(userOId)”) as String