How to convert std::string to NSString?

前端 未结 6 1185
轮回少年
轮回少年 2020-12-07 15:14

Hi I am trying to convert a standard std::string into an NSString but I\'m not having much luck.

I can convert successfully from an N

6条回答
  •  感情败类
    2020-12-07 15:56

    Apple now has a new way they want you to do this conversion. In XCode7, I used the Edit > Convert > To Modern Objective C Syntax... option to find this out. It uses a shorthand @ symbol.

    std::string sCPPString = "Hello World!";
    NSString *sAppleString = @(sCPPString.c_str());
    

提交回复
热议问题