How to convert an NSString into an NSNumber

后端 未结 18 2152
一整个雨季
一整个雨季 2020-11-22 16:56

How can I convert a NSString containing a number of any primitive data type (e.g. int, float, char, unsigned int

18条回答
  •  感情败类
    2020-11-22 17:20

    Try this

    NSNumber *yourNumber = [NSNumber numberWithLongLong:[yourString longLongValue]];
    

    Note - I have used longLongValue as per my requirement. You can also use integerValue, longValue, or any other format depending upon your requirement.

提交回复
热议问题