从 NSDictionary 获取信息 [英] Getting information from a NSDictionary
本文介绍了从 NSDictionary 获取信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将结果命名为 resultdict
并且 NSDictionary
看起来像这样:
I named the result resultdict
and the NSDictionary
looks like this:
{
data = (
);
summary = {
"total_count" = 514;
};
}
我如何从中获得514"?我正在使用 swift.
How do I get the "514" from that? I am using swift.
推荐答案
你可以这样做:
var totalCount = yourDict.objectForKey("summary").objectForKey("total_count")
将其转换为字符串
var totalCount = yourDict.objectForKey("summary").objectForKey("total_count") as! String
如果你使用:
println(totalCount)
将导致
Optional(514)
根据需要使用该变量
这篇关于从 NSDictionary 获取信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文