Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to convert Float64 to NSString in iOS

How to convert Float64 to NSString in objective-c?

like image 926
Namratha Avatar asked Mar 07 '11 06:03

Namratha


2 Answers

How about this:

NSString *str = [NSString stringWithFormat: @"%lf", number];
like image 72
Himadri Choudhury Avatar answered Oct 20 '22 01:10

Himadri Choudhury


You can also use

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

Edit:

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

like image 32
Robin Avatar answered Oct 20 '22 01:10

Robin