我试图在我的解析数据库中创建一个ObjectId和Int数组 . 我的代码中有以下内容,但得到“错误:type()不符合协议'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")
}}
提前致谢 .
1 回答
您需要显式转换要检索的属性: