IOS 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: URLString'
转载自:http://i.cnblogs.com/EditPosts.aspx?postid=4012011
今天想写一个请求的天气,好的,废话不多说,先贴代码:
使用AFNetWorking 发送get请求,但是一直报错 IOS 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: URLString'
翻译出来就是 不能满足urlstring, 可能时请求地址错了,但是请求地址没错,返回是一串json数据,然后我就迷糊了,后来 我发现这个url中参数是直接写上去的
,然后parameters 放参数的地方 没放,后来我把参数单独写了进来,就搞定了啊!
[appDelegate.manager GET:@"http://api.map.baidu.com/telematics/v3/weather?location=南京&output=json&ak=4zG5R7SqnQa" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSDictionary *rootDict=responseObject;
NSLog(@"%@",rootDict);
NSArray *resultArray = [rootDict objectForKey:@"results"];
NSDictionary *cityDict=[resultArray objectAtIndex:];
//获取城市
NSString *currentCity= [cityDict objectForKey:@"currentCity"];
//准备获取天气
NSArray *weatherArray= [cityDict objectForKey:@"weather_data"];
//获取第一天天气的字典
NSDictionary *firstDict=[weatherArray objectAtIndex:];
//获取第一天日期
NSString *firstDate=[firstDict objectForKey:@"date"];
//获取第一天天气
NSString *weather=[firstDict objectForKey:@"weather"];
//获取第一天风向
NSString *wind=[firstDict objectForKey:@"wind"];
//获取第一天气温
NSString *temper=[firstDict objectForKey:@"temperature"];
[[[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"当前城市%@\n日期:%@\n天气%@\n风向%@\n气温%@\n",currentCity,firstDate,weather,wind,temper] message:nil delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil] show];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"链接失败");
}];
});
正确代码:
NSDictionary *parameter=@{@"location": @"南京",@"output": @"json",@"ak": @"4zG5R7Lw8Fd3SqnQa"};
[appDelegate.manager GET:@"http://api.map.baidu.com/telematics/v3/weather" parameters:parameter success:^(AFHTTPRequestOperation *operation, id responseObject) {
这里的参数一定要写再 parameters 中,不然链接里的那些&符号,好像不识别把!
IOS 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: URLString'的更多相关文章
- iOS 9 地图定位崩溃 n: 'Invalid parameter not satisfying: !stayUp || CLClientIsBackgroundable(internal->fClient)'
报错详情: *** Assertion failure in -[CLLocationManager setAllowsBackgroundLocationUpdates:], /BuildRoot/ ...
- 'Invalid parameter not satisfying: body'
afnetwork图片上传的时候出错,出现错误 2015-11-09 15:47:59.086 videoPro[3207:132795] *** Assertion failure in -[AFS ...
- iOS文件上传文件URL错误Invalid parameter not satisfying: fileURL'
一:iOS文件上传提示URL错误 Invalid parameter not satisfying: fileURL' 二:解决方法: NSString *imagePath = [[NSBundle ...
- 安装yii2时出错 Invalid Parameter – yii\base\InvalidParamException
最近composer安装yii2的时候页面报了这个错,应该是bower的前端资源位置改变的缘故! Invalid Parameter – yii\base\InvalidParamException ...
- Oracle 记录插入时“Invalid parameter binding ”错误
出现这种错误的原因可能有一下几种: 由于OracleParameter[] parameters:中parameters的个数和对应的插入SQL语句中的冒号个数不等: 参数个数和冒号个数相等,但是如下 ...
- 关于ImageMagick出现无效参数(invalid parameter)的解决方法
Windows 命令行 运行"convert logo.jpg f:\parseWord\tmp\logo.png" 时显示 “无效参数(Invalid Parameter)” ...
- java.sql.SQLException: Invalid parameter object type. Expected 'java.util.Map' but found 'java.lang.String 转载
java.sql.SQLException: Invalid parameter object type. Expected 'java.util.Map' but found 'java.lang. ...
- Failed to set MokListRT: Invalid Parameter Something as gone seriously wrong: import_mok_state() failed: Invalid Parameter
今天yum update升级centos7,重启后发现开不了机,报错如下: Failed to set MokListRT: Invalid ParameterSomething as gone se ...
- Vue微信自定义分享时安卓系统config:ok,ios系统config:invalid signature签名错误,或者安卓和ios二次分享时均config:ok但是分享无效的解决办法
简述需求:要求指定页面可以进行微信自定义分享(自定义标题,描述,图片,链接),剩下的页面隐藏所有基础接口.二次分享依然可以正常使用,切换至其他页面也可以正常进行自定义分享. 这两天在做微信自定义分享的 ...
随机推荐
- codeforces 390D Inna and Sweet Matrix
几个小结论: 1.路径长度=i+j-1; 2.最简单的走法是先横走再竖着走或者先竖着走再横着走 #include<cstdio> #include<cstring> using ...
- ZOJ 3170 Friends
点我看题目 题意 : 就是有n个人,m对关系,每对关系的两个人是好朋友,这个关系是相互的,如果有两个人的共同好朋友超过k个,那这两个人也会是好朋友的,给你m对关系,给你足够长的时间,问你还能增加几对关 ...
- 修改Tomcat内存大小
Windows下,在文件/bin/catalina.bat,Linux下,在文件/bin/catalina.sh的前面,增加如下设置: JAVA_OPTS=-Xms[初始化内存大小] -Xmx[可以使 ...
- [jobdu]二叉树的镜像
树的镜像,这里的做法就是先序遍历的反过来呗. #include <iostream> #include <vector> using namespace std; void p ...
- SPRING IN ACTION 第4版笔记-第七章Advanced Spring MVC-001- DispatcherServlet的高级配置(ServletRegistration.Dynamic、WebApplicationInitializer)
一. 1.如想在DispatcherServlet在Servlet容器中注册后自定义一些操作,如开启文件上传功能,则可重写通过AbstractAnnotationConfigDispatcherSer ...
- ANDROID_MARS学习笔记_S01原始版_016_Service
一.代码1.xml(1)main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayo ...
- org.springframework.jdbc.datasource
org.springframework.jdbc.datasource.DataSourceUtils /** * Actually obtain a JDBC Connection from the ...
- 逻辑运算符&& 用法解释
A&&B 首先判断A,A成功然后判断B:A不成功则结束判断,返回false;
- Azure HDInsight 现已在中国正式发布
今年月,我们宣布微软成为全球首家在中国公开发布云 Hadoop 产品公共预览版的云提供商.今天,微软非常高兴地宣布 AzureHDInsight现已在中国正式发布.中国本土组织以及在中国设立了办 ...
- HTML特殊字符大全
特殊符号 命名实体 十进制编码 特殊符号 命名实体 十进制编码 ! ! " " " # # $ $ % % & & & ' ...