views:

49

answers:

2

Hi,

Here is what I have:


 smallURL:(@"bundle://image.jpg")

this line will display me a picture store in the local path, no problem everything works fine. Now I'm using an object because the name for my picture will be store in my database, so I want to use the line like that:


 smallURL:(@"bundle://%s", [visuel lpath])

My problem is "%s" its not working do I have to use %@, %i... can someone help me and explain all the diference..

Thanks,

+1  A: 

If lpath is of type NSString then you should use %@. It is used every time you need to convert a Cocoa object (or any other descendant of NSObject) into its string representation.

smallURL:(@"bundle://%@", [visuel lpath])
Alex
It seems to work, thanks. Now I have another problem and I don't know why, when I use what you told me the picture don't want to display and if I use NSLog(@"bundle://%@", [visuel lpath]); the path for the picture is good --> bundle://image.jpg
ludo
I beleive that Niels Castle has already answered that question in his comment to the Hoang's answer. The right decisiion is to use the syntax suggested by Hoang.
Alex
+2  A: 

smallURL:([NSString stringWithFormat:@"bundle://%@", [visuel lpath]])

sfa
Thanks its working now, but why do I have to pecify NSString again? I don't understand.
ludo
NSLog is special. It supports recieving both a string with a format and its parameters. smallURL only takes one parameter, a string. In order for the single parameter to smallURL to be correctly formatted we have to first create a new string with a format and then pass the resulting foratted string to smallURL.
Niels Castle