How to convert std::string to NSString?

前端 未结 6 1190
轮回少年
轮回少年 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:48

    Get c-string out of std::string for conversion:

    NSString *errorMessage = [NSString stringWithCString:REALM.c_str() 
                                       encoding:[NSString defaultCStringEncoding]];
    

提交回复
热议问题