NSString转NSInteger,int,字符串
NSString *str1 = @"123";
NSString *str2 = @"456";
// 1,字符串拼接
NSString *newString = [NSString stringWithFormat:@"%@%@",str1,str2];
NSLog(@"newString =%@", newString);
//2,字符转NSInteger
NSInteger a = [newString integerValue];
NSLog(@"aaaaa =%ld", newString);
//2,NSInteger转字符
NSString *b = [NSString stringWithFormat:@"%ld",a];
NSLog(@"bbbbb=%@", b );
//2,字符转int
int intString = [newString intValue];
NSLog(@"intString =%d", intString);
//3,int转字符
NSString *stringInt = [NSString stringWithFormat:@"%d",intString];
NSLog(@"stringInt =%@", stringInt);
//4,字符转float
float floatString = [newString floatValue];
NSLog(@"floatString =%f", floatString);
//5,float转字符
NSString *stringFloat = [NSString stringWithFormat:@"%f", floatString];
NSLog(@"stringFloat =%@", stringFloat);
如果文章帮到您,喜欢点个赞,谢谢您。
文章内容出错,记得留言,感激不尽。