NSString转char类型数组
NSString *aaa = @"abcdefg";
unsigned char css[aaa.length];
memcpy(css, [aaa cStringUsingEncoding:NSUTF8StringEncoding], aaa.length);
for (int i = 0; i < sizeof(css); i++) {
NSLog(@"%d======%c",i,css[i]);
}
char数组转NSString,这里就直接遍历拼接
NSMutableString *mustr = [NSMutableString string];
for (int i = 0; i < sizeof(css); i++) {
[mustr appendFormat:@"%c",css[i] ];
}
NSLog(@"%@",mustr);
网友评论