NSDictionary是否始终提供双引号括起来的输出?

时间:2011-07-16 07:02:49

标签: iphone

这是我的代码:

//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总是在“”中给出输出吗? 我不希望字符串在“”。

2 个答案:

答案 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中的有效索引和字典对象。