如何在swift中获得这样的输出
{length=30,contents=“something”,count=32.3} 我需要这个括号中的精确输出{}而不是()或[] 我需要像如何在swift中获得这样的输出,swift,nsdictionary,Swift,Nsdictionary,{length=30,contents=“something”,count=32.3} 我需要这个括号中的精确输出{}而不是()或[] 我需要像 [{ name = "this is another", "planned_revenue" = "0.0", phone = "", description = "Internal Notes", ..... }] 首先,您需要一个字典,而不是一组字典。使用Swift,您可以使用Dictionary而不是NSDictionary(Dictionar
[{ name = "this is another", "planned_revenue" = "0.0", phone = "", description = "Internal Notes", ..... }]
首先,您需要一个字典,而不是一组字典。使用Swift,您可以使用
Dictionary
而不是NSDictionary
(Dictionary
或[String:Any]
):
查看和获取更多信息。这是
[AnyHashable:Any]
打印({length=30,contents=\'something\',count=32.3}”)
。然而我不认为那是你想要的。您需要添加有关此输出来自何处的更多信息。print({length=30,contents=\'something\,count=32.3}”)
我想在字典中执行此操作@安布,卡提克,为什么-1?而不是帮助?我们花在帮助上的时间比你详细阐述你的问题要多。如果您需要更多帮助,请尝试添加更多细节并缩小问题范围。非常感谢@红色84:)
[{
name = "this is another";
}, {
"planned_revenue" = "0.0";
}, {
phone = "";
}, {
description = "Internal Notes";
}, {
"email_from" = "thomas.passot@agrolait.example.com";
}, {
probability = "20.0";
}]
[{ name = "this is another", "planned_revenue" = "0.0", phone = "", description = "Internal Notes", ..... }]
let dict: [String: Any] = [
"name": singleItem.name,
"planned_revenue": singleItem.planned_revenue,
"phone": singleItem.phone,
"description": singleItem.description,
"email_from": singleItem.email_from,
"probability": singleItem.probability
]
// If you need a NSDictionary, you can cast it
let nsDict = dict as NSDictionary