开发者

Converting NSString into const char

开发者 https://www.devze.com 2023-03-14 04:56 出处:网络
I have an String and i want to conv开发者_C百科ert it into Const Char . I Had tried but it\'s not Working

I have an String and i want to conv开发者_C百科ert it into Const Char . I Had tried but it's not Working

NSString *str4 = [NSString stringWithUTF8String:character];


Do like this:

NSString *strSQL = [[NSString alloc]init];

then something in your *strSQL

then this statement:

const char *bar = [strSQL UTF8String]; 


NSString *myString = @"Hello";  

const char *cString = [myString cStringUsingEncoding:NSASCIIStringEncoding];

or

const char * cstr2 = [ myString UTF8String ];


You should use cStringUsingEncoding: method
Take a look at this method here

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号