//加载服务器指定地址的URL:configURL带上projectId
NSString *requestUrl = [NSString stringWithFormat:@"%@/%@",configURL,projectId];
NSLog(@"requestUrl= %@",requestUrl);
//同步执行Http请求,获取返回数据
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:requestUrl]];
NSError *requestError ;
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&requestError];
//(如果有错误)错误描述
if (requestError!=nil) {
NSLog(@"requestError=%@",requestError);
}
NSLog(@"returnData=%@",returnData);
//返数据转成字符串
NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
NSLog(@"returnString=%@",returnString);
网友评论