Convert a string into an int

后端 未结 11 2480
别跟我提以往
别跟我提以往 2020-12-04 14:51

I\'m having trouble converting a string into an integer. I googled it but all I can find is how to convert an int into a string. Does anyone know how to do it the other way

11条回答
  •  南笙
    南笙 (楼主)
    2020-12-04 15:40

    How about

    [@"7" intValue];
    

    Additionally if you want an NSNumber you could do

    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter numberFromString:@"7"];
    

提交回复
热议问题