NSNumber轉(zhuǎn)NSString:
假設(shè)現(xiàn)有一NSNumber的變量A,要轉(zhuǎn)換成NSString類(lèi)型的B
方法如下:
NSNumberFormatter* numberFormatter = [[NSNumberFormatteralloc] init];
B = [numberFormatter stringFromNumber:A];
[numberFormatter release];
nsstring和float 還有int之間的轉(zhuǎn)換
NSString *tempA = @"123";
NSString *tempB = @"456";
1做瞪,字符串拼接
NSString *newString = [NSString stringWithFormat:@"%@%@",tempA,tempB];
2畸裳,字符轉(zhuǎn)int
int intString = [newString intValue];
3,int轉(zhuǎn)字符
NSString *stringInt = [NSString stringWithFormat:@"%d",intString];
4滑频,字符轉(zhuǎn)float
float floatString = [newString floatValue];
5捡偏,float轉(zhuǎn)字符
NSString *stringFloat = [NSString stringWithFormat:@"%f",intString];
///////