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 |
Is python static or dynamic?
Is objective c superset of c?
What is kvc and kvo? Give an example of using kvc to set value.
What is an extension?
What is dynamic dispatch method?
Can a protocol have properties?
How do I create an objective c class in xcode?
What is the main difference between function calls and messages?
What is m files document management?
What are properties and instance variables in objective c and swift?
Why swift is faster than objective c?
Explain what is protocol in objective-c?