开发者

How to convert hexadecimal string to decimal?

开发者 https://www.devze.com 2023-03-06 09:30 出处:网络
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. Thanks in advance.开发者_运维技巧The easiest way i

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. Thanks in advance.开发者_运维技巧


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

精彩评论

暂无评论...
验证码 换一张
取 消