How to convert hexadecimal string to decimal?

前端 未结 1 670
小鲜肉
小鲜肉 2021-01-26 00:15

I would appreciate it if you could tell me how I can convert hexadecimal letters within an NSString, e.g. @\"50A6C2\", to decimals using Objective-C. T

1条回答
  •  礼貌的吻别
    2021-01-26 00:37

    The easiest way is to use an NSScanner, specifically the methods scanHexInt: or scanHexLongLong:. Another possibility is to get the C string from the NSString and use C-style functions such as strtol (with base 16).

    0 讨论(0)
提交回复
热议问题