So I have an NSMutableDictionary that I populate, but when I output the contents to NSLog, the key and value for the entries entered in the for loop show up differently, and the final NSLog call doesn't even output anything. What's going on here??? Please help! Why are the quotes around the entries added in 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"]);
Output of NSLog (I only added one value in the for loop: "SourceName_0" = "tbyg.jpg", but why the quotes around "SourceName_0"??? Whatever is happening here is preventing me from accessing that dictionary entry...
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)
The quotes appear because the string contains something besides basic alphanumerics — in this case, an underscore. It's the same reason "tbyg.jpg"
and "6bcb4126-4bbe-4b3d-be45-9a06cf56a22f"
have quotes (they contain a dot and dashes, respectively). That's just how the description
method works. It wouldn't cause your second log to fail.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With