How to convert Float64 to NSString in iOS

How to convert Float64 to NSString in objective-c?

+6
floating-point objective-c iphone nsstring
source share
2 answers

How about this:

 NSString *str = [NSString stringWithFormat: @"%lf", number]; 
+8
source share

You can also use

 NSString *str = [[NSString alloc] initWithFormat: @"%lf", number]; 

Edit:

The difference is that you need to release str variable in this case when you are done with it. We use the init method to initialize class variables so that they can be accessed through the class and then freed them in dealloc .

+3
source share

All Articles