这是我的代码:
//elementsValues is type of NSDictionary. currentElementValue is type of NSString.
//resultArray is type of NSArray.
//elementName = [[NSString stringWithFormat:@"SignOnResult"];
[self.elementsValues setObject:self.currentElementValue forKey:elementName];
[self.resultArray addObject:self.elementsValues];
NSLog(@"%@",[resultArray valueForKey:@"SignOnResult"]);
我得到的输出打印在“”之间。那么NSDictionary总是在“”中给出输出吗? 我不希望字符串在“”。
答案 0 :(得分:0)
NSDictionary *dictionary = [self.resultArray objectAtIndex:0];
NSLog(@"%@",dictionary);
答案 1 :(得分:0)
使用valueForKey:
实例调用resultArray
时出错了,它会返回空的NSArray
,
NSLog(@"%@",[resultArray valueForKey:@"SignOnResult"]); // wrong statement
尝试更改为
NSLog(@"%@",[[resultArray objectAtIndex:dictionaryIndex] valueForKey:@"SignOnResult"]);
此处dictionaryIndex
是整数类型,并指向resultArray
中的有效索引和字典对象。