各位亲 有时间可以去看看我的 “金骏家居淘宝店” http://jinjun1688.taobao.com/shop/view_shop.htm?tracelog=twddp 买时说明在我的博客看到有优惠哦 还有意外礼品赠送 真正的程序员淘宝店
NSString *tempA = @"123";
NSString *tempB = @"456";
1,字符串拼接
NSString *newString = [NSString stringWithFormat:@"%@%@",tempA,tempB];
2,字符转int
int intString = [newString intValue];
3,int转字符
NSString *stringInt = [NSString stringWithFormat:@"%d",intString];
4,字符转float
float floatString = [newString floatValue];
5,float转字符
NSString *stringFloat = [NSString stringWithFormat:@"%f",intString];
C字符串与NSString之间的转换
代码:
[cpp]
const char *cString = "这是一个C字符串, c string";
NSString *nsstring = @"这是个NSString字符串, nsstring";
NSLog(@"cString字符串-->%s ",cString);
NSLog(@"NSString字符串-->%@",nsstring);
const char *cString2 = [nsstring UTF8String];
NSString *nsstring2 = [NSString stringWithUTF8String:cString];
NSLog(@"cString2字符串-->%s ",cString2);
NSLog(@"NSString2字符串-->%@",nsstring2);
---------------------
将第n个进行转换
char r = [strValue characterAtIndex:n];
int i = [strValue characterAtIndex:n]-'0';