sprintf with NSString

So, I have been struggling to learn Objective C. Here is a snippet of code that might be helpful. Basically you can use NSString’s initWithFormat method to create a new NSString object and use it just like sprinf function in C

[[NSString alloc] initWithFormat:@”(%f,%f)”,center.x,center.y]   

3 Responses to “sprintf with NSString”

  1. Chris Says:

    Thanks! I too am learning Objective-C and have been trying to figure out an NSString-style sprintf. This does the trick.

  2. Roger Says:

    Thanks! This post was very helpful to me :)
    Short and consise, just the way it should be!
    mvh roger

  3. kiichi Says:

    [NSString stringWithFormat:@"(%f,%f)",center.x,center.y]

Leave a Reply