获取本地ip(家里的公网ip)

AFHTTPSessionManager *client = [[AFHTTPSessionManager alloc] init];
        client.requestSerializer = [AFHTTPRequestSerializer serializer];
        client.responseSerializer = [AFJSONResponseSerializer serializer];
        client.requestSerializer.timeoutInterval = 30.0f;
        [client GET:@"http://ipinfo.io/json" parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
            if (responseObject) {
                NSDictionary *dicContent = responseObject;
                ip = [dicContent objectForKey:@"ip"];
            }
            
        } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
            ip = @"0.0.0.0";
        }];

你可能感兴趣的:(获取本地ip(家里的公网ip))