我正在尝试将[NSDate: Double]
类型的字典保存到PFUser.currentUser's
记录中:
let user = PFUser.currentUser()!
let date = NSDate()
user["savedDictionary"] = [date: 1.0] // error, see below. ["test": 1.0] works though
user.saveInBackgroundWithBlock { (success: Bool, error: NSError?) -> Void in
if error == nil {
print("Dictionary uploaded!")
} else {
print(error)
}
}
我得到的错误:
Caught "NSInvalidArgumentException" with reason "Invalid (non-string) key in JSON dictionary":
此错误还会导致PFUser.currentUser
注销。
答案 0 :(得分:1)
将日期键转换为字符串:
Here is my code:
var firstPart;
var secondPart;
var str = "hello123"
alert(str.split(""));