NSNumber转NSString:

假设现有一NSNumber的变量A,要转换成NSString类型的B

方法如下:

NSNumberFormatter* numberFormatter = [[NSNumberFormatteralloc] init];

B = [numberFormatter stringFromNumber:A];

[numberFormatter release];

 

nsstring和float 还有int之间的转换

 

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];

posted on 2016-01-09 14:50  哦呵呵呵哦  阅读(153)  评论(0编辑  收藏  举报