Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSMutableDictionary is adding quotes to keys and values - why?

I'm trying to add some additional key/value pairs to an NSMutableDictionary, using:

Tag *tag1 = [results1 objectAtIndex:0];
[resultsDict setObject:[tag1 retrieveTextUpToDepth:1] forKey:@"image_url"];

Tag *tag2 = [results2 objectAtIndex:0]; 
[resultsDict setValue:[tag2 retrieveTextUpToDepth:1] forKey:@"majority"];

This adds the k/v pairs with no problem, except when I come to retrieve them, some of the values have been wrapped with double quotes:

po extendedDataDictionary:

    "image_url" = "/images/mpsL/11727.jpeg";
    majority = 3460;

Both keys and values are NSStrings, with no quotes - so I'm stumped as to where they're appearing from.

Is there any way of preventing this?

Or am I going to have to live with it and try to strip off the quotes once I've retrieved the value?

Thanks...

like image 558
TimD Avatar asked Mar 18 '10 16:03

TimD


People also ask

What is NSMutableDictionary in swift?

The NSMutableDictionary class declares the programmatic interface to objects that manage mutable associations of keys and values. It adds modification operations to the basic operations it inherits from NSDictionary . NSMutableDictionary is “toll-free bridged” with its Core Foundation counterpart, CFMutableDictionary .

What is NSMutableDictionary?

NSDictionary creates static dictionaries, and NSMutableDictionary creates dynamic dictionaries. (For convenience, the term dictionary refers to any instance of one of these classes without specifying its exact class membership.) A key-value pair within a dictionary is called an entry.


1 Answers

The quotes aren't really part of the content; the -description method (called by po, IIRC) simply wraps things in quotes for display that have non-alphanumeric characters in them.

like image 76
Wevah Avatar answered Sep 20 '22 20:09

Wevah