Printing an NSString

后端 未结 6 1299

What\'s the correct way to print an NSString in Objective-C? A lot of examples use NSLog(), but according to the documentation:

NSLog is a FoundationK

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-13 19:55

    I just do:

    define NSPrintf(...)   printf( "%s", [[NSString stringWithFormat: __VA_ARGS__] UTF8String] )
    

    Then i can use it as:

    NSPrintf( @"Sorry %@, I can't do that\n", name );
    

提交回复
热议问题