我通过 JSON 检索 IP 地址作为无符号长整数。我正在尝试将其转换回人类可读的形式,即 xxx.xxx.xxx.xxx。
我在 JSON 中收到的示例:
"ip": 704210705
我有点挣扎,因为 C 从来都不是我的强项。我在下面收到 EXC Bad Access 错误:
unsigned long int addr = [[user objectForKey:@"ip"] unsignedLongValue];
struct in_addr *remoteInAddr = (struct in_addr *)addr;
char *sRemoteInAddr = inet_ntoa(*remoteInAddr);
我在 char 行 (3) 上得到错误。
谁能给我任何建议?