How to convert string to nsnumber in objective c?
Answer / Km. Arti
To convert a string to an NSNumber object in Objective-C, you can use the following code:
```objectivec
NSString *yourString = @"42";
NSNumber *number = [yourString numberWithInteger:[yourString integerValue]]; // for integer values
// For floating point numbers:
double yourDouble = 3.14;
NSString *yourStringDouble = [NSString stringWithFormat:@"%f", yourDouble];
NSNumber *numberDouble = [yourStringDouble numberWithDouble:yourDouble];
```
| Is This Answer Correct ? | 0 Yes | 0 No |
What is an m file?
Explain how to call a function in objective-c?
Is objective c similar to java?
What is difference between nil and nill?
How different is objective c from swift?
How does dispatch_once manages to run only once?
Is objective c type safe?
What happens when you create a block?
Is closure a function?
What is class extension? Why do we require them?
What is the difference between underscore and self (i.e self.xx and _xx) ?
How would I make a static strategy?