根据ip可以获取到具体位置

来源:互联网 发布:恺英网络工作怎么样 编辑:程序博客网 时间:2024/04/27 20:58

NSString *strURL = [@"http://webservice.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx/getCountryCityByIp?theIpAddress="stringByAppendingString:@"123.150.2.33"];

    //转换为URL

   NSURL *pURL = [NSURLURLWithString:strURL];

    //创建请求

   NSURLRequest *pRequest = [NSURLRequestrequestWithURL:pURL];

    NSData *DATA = [NSURLConnectionsendSynchronousRequest:pRequest returningResponse:nilerror:nil];

    NSString *IP_Address = [[NSStringalloc] initWithData:DATAencoding:NSUTF8StringEncoding];

0 0