Why is the string displayed in NSDictionary with quotes and others not?

So, I have an NSMutableDictionary that I populate, but when I output the contents to the NSLog, the key and value for the entries entered in the for loop look different and the final call to NSLog does not even output anything. What's going on here? Please help! Why are quotation marks around entries added to the for loop?

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: numberOfPhotosAsString, @"PackageFileCount", wtID, @"wtID", uploadType, @"type", nil]; for (int i= 0; i < photos.count; i++) { NSString *finalFileName = [fileNameBase stringByAppendingFormat:@"%i", i]; [params setObject:[[fileNames objectAtIndex:i] stringByAppendingString:@".jpg"] forKey:finalFileName]; // This one doesn't do anything differently: //[params setValue:[[fileNames objectAtIndex:i] stringByAppendingString:@".jpg"] forKey:[fileNameBase stringByAppendingFormat:@"%i", i]]; } NSLog(@"Params: %@", params); NSLog(@"Value: %@", [params objectForKey:@"SourceName_0"]); 

NSLog output (I added only one value to the for loop: "SourceName_0" = "tbyg.jpg", but why are the citations around "SourceName_0"? Whatever happens, this prevents me from accessing this entry in the dictionary ...

Log:

 2012-05-09 12:38:26.448 PhotoUp[6231:707] Params: { PackageFileCount = 1; "SourceName_0" = "tbyg.jpg"; type = T; wtID = "6bcb4126-4bbe-4b3d-be45-9a06cf56a22f"; } 2012-05-09 12:38:26.449 PhotoUp[6231:707] Value: (null) 
+4
source share
1 answer

Quotation marks appear because a string contains something other than basic alphanumeric characters — in this case, an underscore. For the same reason, "tbyg.jpg" and "6bcb4126-4bbe-4b3d-be45-9a06cf56a22f" have quotation marks (they contain a dot and a dash, respectively). This is how the description method works. This will not crash your second log.

+12
source

Source: https://habr.com/ru/post/1411583/


All Articles