【发布时间】:2015-05-30 06:51:58
【问题描述】:
我正在尝试在我的解析数据库中创建一个 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")
} }
提前致谢。
【问题讨论】:
-
“怎么了? -
@tskulbru 复制粘贴造成了一些问题。抱歉,已编辑。现在你能帮忙消除错误吗?
标签: ios swift parse-platform