从NSDictionnary检索值 [英] Retrieve value from NSDictionnary
本文介绍了从NSDictionnary检索值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个NSDictionary,但我不知道如何检索"@mode"和"@route"的值(这是来自json响应).
I have a NSDictionary and I don't know how I can retrieve the value of "@mode" and "@route" (this is from a json response).
我该怎么做?
谢谢!
这是NSDictionary:
This is the NSDictionary :
{
"@mode" = WALK;
"@route" = "Rue University";
distance = "17.513516908661757";
duration = 13000;
endTime = "2011-04-29T12:08:59.395-04:00";
from = {
geometry = "{\"type\": \"Point\", \"coordinates\": [-73.57120386807037,45.503820214186405]}";
lat = "45.503820214186405";
lon = "-73.57120386807037";
name = "Rue University";
};
legGeometry = {
length = 3;
points = "{mvtG`k``MOd@ME";
};
startTime = "2011-04-29T12:08:46.395-04:00";
steps = {
walkSteps = (
{
absoluteDirection = NORTHWEST;
becomes = false;
distance = "17.513516908661757";
elevation = "";
lat = "45.503820214186405";
lon = "-73.57120386807037";
stayOn = false;
streetName = "Rue University";
},
{
absoluteDirection = NORTH;
becomes = true;
distance = "0.0";
elevation = "";
lat = "45.50390573910769";
lon = "-73.57139257694809";
relativeDirection = RIGHT;
stayOn = false;
streetName = "street transit link";
}
);
};
to = {
geometry = "{\"type\": \"Point\", \"coordinates\": [-73.571363,45.503971]}";
lat = "45.503971";
lon = "-73.571363";
name = "Station McGill";
stopId = 32;
};
推荐答案
类似于索引0的对象是NSDictionary.
Looks like object at index 0 is a NSDictionary.
NSDictionary *dict = [array objectAtIndex:0];
NSString *route = [dict objectForKey:@"@route"];
这篇关于从NSDictionnary检索值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文