How to bridge Swift String to Objective C NSString?

前端 未结 3 2340
我寻月下人不归
我寻月下人不归 2021-02-13 10:12

Am I taking crazy pills? Directly out of the documentation:

“Swift automatically bridges between the String type and the NSString class. This means that

3条回答
  •  一整个雨季
    2021-02-13 10:17

    Here is example for this :

    string str_simple = "HELLO WORLD";
    
    //string to NSString
    NSString *stringinObjC = [NSString stringWithCString:str_simple.c_str()
                                    encoding:[NSString defaultCStringEncoding]];            
    NSLog(stringinObjC);
    

提交回复
热议问题