数据类型转string
float f = xxx;
NSString strF = [NSString stringWithFormat:@"%f", f];
//int和double一样, %d和%f
string转数据类型
NSString @strF = xxx;
int f = [strF floatValue];
// intValue, doubleValue
本文详细介绍了在Objective-C编程语言中如何将不同数据类型转换为字符串,以及如何从字符串中解析出各种数据类型,包括float、int和double。通过示例代码展示了使用stringWithFormat方法和floatValue、intValue、doubleValue属性进行类型转换的具体实现。
数据类型转string
float f = xxx;
NSString strF = [NSString stringWithFormat:@"%f", f];
//int和double一样, %d和%f
string转数据类型
NSString @strF = xxx;
int f = [strF floatValue];
// intValue, doubleValue
791
3366

被折叠的 条评论
为什么被折叠?