***********

#import "HMViewController.h"
#import "MBProgressHUD+MJ.h" @interface HMViewController () @end @implementation HMViewController - (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
} - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
// 1.URL
NSURL *url = [NSURL URLWithString:@"http://localhost:8080/MJServer/weather"]; // 2.请求
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; // 3.请求方法
request.HTTPMethod = @"POST"; // 4.设置请求体(请求参数)
NSMutableString *param = [NSMutableString string];
[param appendString:@"place=beijing"];
[param appendString:@"&place=tianjin"];
[param appendString:@"&place=meizhou"];
request.HTTPBody = [param dataUsingEncoding:NSUTF8StringEncoding]; // 5.发送请求
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
if (data == nil || connectionError) return;
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
NSString *error = dict[@"error"];
if (error) {
[MBProgressHUD showError:error];
} else {
// NSArray *weathers = dict[@"weathers"];
NSLog(@"%@", dict);
}
}];
} @end

IOS网络第二天 - 09-多值参数的更多相关文章

  1. IOS网络第二天 - 07-发送JSON给服务器

    *************** #import "HMViewController.h" #import "MBProgressHUD+MJ.h" @inter ...

  2. IOS网络第二天 - 04-黑酷-GDataXML 解析

    ****** - (void)viewDidLoad { [super viewDidLoad]; /** 加载服务器最新的视频信息 */ // 1.创建URL NSURL *url = HMUrl( ...

  3. IOS网络第二天 - 03-JSON显示数据,调用本地视频播放,数据转模型

    ********HMVideosViewController.m #import "HMVideosViewController.h" #import "MBProgre ...

  4. IOS网络第二天 - 01-基本的HTTP请求

    ***************** #import "HMViewController.h" #import "MBProgressHUD+MJ.h" @int ...

  5. IOS网络第二天 - 06-POST请求

    ************POST请求 #import "HMViewController.h" #import "MBProgressHUD+MJ.h" @in ...

  6. IOS网络第二天 - 02-异步HTTP请求block回调 解析

    ************** #import "HMViewController.h" #import "MBProgressHUD+MJ.h" @interf ...

  7. iOS开发网络篇—发送json数据给服务器以及多值参数

    iOS开发网络篇—发送json数据给服务器以及多值参数 一.发送JSON数据给服务器 发送JSON数据给服务器的步骤: (1)一定要使用POST请求 (2)设置请求头 (3)设置JSON数据为请求体 ...

  8. [iOS 多线程 & 网络 - 2.6] - 使用POST上传JSON数据 & 多值参数

    A.上传JSON 1.思路: 必须使用POST方法才能上传大量JSON数据 设置请求头:设置Content-Type 设置请求体,JSON实际相当于字典,可以用NSDictionary NSJSONS ...

  9. 【转】iOS开发网络篇—发送json数据给服务器以及多值参数

    原文: http://www.cnblogs.com/wendingding/p/3950132.html 一.发送JSON数据给服务器 发送JSON数据给服务器的步骤: (1)一定要使用POST请求 ...

随机推荐

  1. DAY5 python内置函数+验证码实例

    内置函数 用验证码作为实例 字符串和字节的转换 字符串到字节 字节到字符串

  2. 两个int的和判断溢出

    long a,b; cin>>a>>b; long i; i = a+b; if((i^a)<0 && (i^b)<0) cout<<& ...

  3. AngularJS 配置和运行phonecat错误

    安装node.js 就按照入门上的步骤来就行了 第一步:下载安装node.js,并将程序路径添加到环境变量中PATH中 第二步:下载git版本控制软件 第三步:在git目录下点击git-bash.ex ...

  4. 2.mongoDB add user in v3.0 问题的解决(Property 'addUser' of object admin is not a func)

    问题:创建mongodb帐户时,出错 > db.addUser('jyu', 'aerohive')  2015-08-05T20:03:02.767+0800 E QUERY    TypeE ...

  5. Velocity简单语法及VelocityHelper封装

    1.简单替换##这是注释Wellcome ${userName}! Now:$date 2.申明变量:#set( $iAmVariable = "good!" )Welcome $ ...

  6. python 3.5.2 install pillow

    1. 首先尝试从官网下载, pip install pillow, 结果网络不行,总是连不上或者下载中就失败, C:\Windows\system32>pip install pillowCol ...

  7. Other Linker Flags到底是什么

    一.问题描述 在项目开发中用到百度地图,有时候在工程中会报“方法找不到”的错误(unrecognized selector sent to instance). 二.问题分析 首先,要说明一下Othe ...

  8. 在VFP6中模拟CursorAdapter的功能

    这个是我在2002年做的一个VFP程序中实现的方法, 现在看来功能和VFP8,9中的CursorAdapter非常相似, 因为属性设置有许多相同的地方,我甚至怀疑CA就是就是在这样的基础上再包装出来的 ...

  9. MVC+Easeyui dialog的小问题

    今天在尝试 MVC+Easyui的练习中遇到的一些,小问题. 在.net MVC 中  在_layout.cshtml中设置Easyui 环境  ,在传到子页中,发现$("#dlg" ...

  10. unity3d编辑器——检视面板部分(一)

    最近在学习unity编辑器,so,记录总结一下. 以下介绍了一些简单的unity3d检视面板部分的使用技巧. using UnityEngine; using System.Collections; ...