How to covert the IP address from NSString to unsigned int in Objective-C?
NSString A = "192.168.43.149"
And I try to convert it to unsigned int like the following code:
unsigned int ip;
ip = (unsigned int)[A intValue];
or
sscanf([A UTF8String], "%u", &ip);
The result always show only 192.
I want it show 0xc0a82b95
How to covert the IP address from NSString to unsigned int in Objective-C?
Thanks in advance.
For IPv4 addresses you can use
inet_aton(), which converts a string to an Internet address: