我想从我的NSDictionary检索值,但是我遇到了错误,我想知道如果有人能够帮助我解决我的问题。从NSDictionary返回值
我有18个值,并不是所有的显示在这里,我正在检查,当正确的键已达到我想在NSDictionary中的值,并将其传递到我的NSString变量之一。
下面是什么我想就像我说的,我有几个问题
for (id key in searchData) {
if ([[searchData objectForKey:key] isEqualToString:@"Code"]) {
codeSeries = [searchData objectForKey:key];
}
else if ([[searchData objectForKey:key] isEqualToString:@"ID"]) {
IDSeries = [searchData objectForKey:key];
}
// ...
但是,当我尝试登录的任何值,以做不过的例子,他们都返回Null
。我已经在手边检查过字典,并且所有值都绝对存在,所以我认为上面的代码有问题。
任何帮助将不胜感激。
更新
这是我创建的NSDictionary
//start of mymethod...
NSDictionary *sendSeriesDictionary = [[NSDictionary alloc] init];
// Keys for sendSeriesDictionary
NSArray *keys = [NSArray arrayWithObjects:@"Code", @"ID", nil];
// Objects for keys that are for sendSeriesDictionary
NSArray *objects = [NSArray arrayWithObjects: [NSNull null], IdString, nil];
// Add keys and objects to NSDictionary
sendSeriesDictionary = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
[engineRequests SeriesSearch:sendSeriesDictionary]; // this is where I send the NSDictionary over to where I want to read it.
//end of mymethod
完美!!!!! :)非常感谢..是的,我不知道为什么我没有没有像原来的NSDictionary一样删除...我认为我做了两部分代码,并没有轮到清理它。 – HurkNburkS 2012-07-25 01:14:45