Printing an NSString

后端 未结 6 1294

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:52

    C string (UTF8String) is a pointer to a structure inside the string object.

    NSString *str = @"Hello, World.";
    printf("%s\n", [str UTF8String]);
    

提交回复
热议问题