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 #import?
What are the blocks? How will you use them?
Is objective c the same as c++?
Is swift objective c?
Explain the way messaging works in objective-c?
Can a static library (.a) contain resources like images, sound files etc?
What is property and its types?
Explain what do you mean by synthesized in objective-c?
What is an objective statement?
What are objective c properties?
What is mark and sweep algorithm?
What do you mean by @synthesize and @dynamic in the objective-c? And also explain what do you mean by synthesized in objective-c?