Saturday, 15 May 2010

iOS Conversion from a dictionary to a NSString -



iOS Conversion from a dictionary to a NSString -

i have nsmutabledictionary holding exif metadata picture. example:

const cfstringref kcgimagepropertyexifexposuretime;

instead of accessing every key individually, want write whole dictionary content label. when want write info console use:

nslog(@"exif dic properties: %@",exifdictionary );

that works fine, if use:

nsstring *exifstring = [nsstring stringwithformat:(@"exif properties: %@", exifdictionary)];

i warnings result not string literally , if seek utilize string set label.text, programme crashes.

any thought error is?

[nsstring stringwithformat:(@"exif properties: %@", exifdictionary)] not, may think, method 2 arguments. it's method 1 argument. 1 argument (@"exif properties: %@", exifdictionary), uses comma operator , ends returning exifdictionary. in essence have

[nsstring stringwithformat:exifdictionary]

which wrong. why you're getting warning. warning tells format argument not string literal, because using variables format strings mutual source of bugs. more importantly here, argument isn't string @ all, , crashes.

remove parentheses , fine. like

[nsstring stringwithformat:@"exif properties: %@", exifdictionary];

ios nsstring nsdictionary

No comments:

Post a Comment