【发布时间】:2014-11-15 17:02:38
【问题描述】:
我正在尝试将具有关键价格的对象转换为 NSString,但无论我做什么,我都会在下一行收到 lldb 错误
arrayDic.setValue(object.objectForKey("price") as NSString, forKey: "price")
当我删除它时,没有错误。 object.objectForKey("price") 是解析数据库中的数字类型。如何正确将其转换为字符串?
代码:
func loadItems() {
var query = PFQuery(className:"Items")
query.orderByAscending("createdAt")
query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]!, error: NSError!) -> Void in
if error == nil {
for object in objects {
arrayDic.setValue(object.objectForKey("price") as NSString, forKey: "price")
arrayDic.setValue(image, forKey: "image")
}
} else {
// Log details of the failure
NSLog("Error: %@ %@", error, error.userInfo!)
}
}
}
【问题讨论】:
-
将语句分解成多条语句,找出错误所在。
标签: ios swift parse-platform