开发者

Does NSDictionary always give output surrounded by double quotes?

开发者 https://www.devze.com 2023-03-20 13:37 出处:网络
This is my code: //elementsValues is type of NSDictionary. currentElementValue is type of NSString. //resultArray is type of NSArray.

This is my code:

//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 valu开发者_C百科eForKey:@"SignOnResult"]);

The output i get is printed in between " ". So does NSDictionary give output always in " " ? I dont want the string in " ".


You are doing wrong for calling valueForKey: with resultArray instance it will return you the empty NSArray,

NSLog(@"%@",[resultArray valueForKey:@"SignOnResult"]); // wrong statement

Try to change as

NSLog(@"%@",[[resultArray objectAtIndex:dictionaryIndex] valueForKey:@"SignOnResult"]);

Here dictionaryIndex is the integer type and point the valid index and dictionary object in your resultArray .


NSDictionary *dictionary = [self.resultArray objectAtIndex:0];

NSLog(@"%@",dictionary);
0

精彩评论

暂无评论...
验证码 换一张
取 消