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但是分享无效的解决办法
简述需求:要求指定页面可以进行微信自定义分享(自定义标题,描述,图片,链接),剩下的页面隐藏所有基础接口.二次分享依然可以正常使用,切换至其他页面也可以正常进行自定义分享. 这两天在做微信自定义分享的 ...
随机推荐
- CF Codeforces Round #231 (Div. 2)
http://codeforces.com/contest/394 话说这次CF做的超级不爽,A题一开始交过了,我就没再管,B题还没看完呢,就死困死困的,后来觉得B题枚举一下估计能行,当时是觉得可以从 ...
- mjpg-streamer on raspberrypi
http://sourceforge.net/projects/mjpg-streamer/ svn address svn checkout svn://svn.code.sf.net/p/mjpg ...
- simplemodal — jquery弹出窗体插件
方式一:使用jquery-1.7.1.min.js(1.9.1的版本我试过了,不行) + jquery_modal.js的方式 文件: testModel.css: /* Overlay ...
- CentOS镜像163更新源
首先备份/etc/yum.repos.d/CentOS-Base.repo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-B ...
- Android 带着用户名的SharedPreferences
/** * 设置当前用户的签到信息 * account&info;account&info * * @param context * @param sign * @author jrj ...
- [置顶] *p++/*++p区别-linux
#include <stdio.h> main() { char * s = "123456"; char * p; p = s; printf( "%c\n ...
- hadoop2.2编程: 数据压缩
本文主要讨论hadoop的数据压缩与解压缩代码的书写 Compressing and decompressing streams with CompressionCodec import org.ap ...
- bzoj1056
花了一上午大概复习了一下splay,treap 像这种裸的数据结构题在js应该会越来越少 不过练练手也好, 这就是平衡树+hash,如果这是单纯的BST应用,还是写treap吧,好调试 ; ...
- BZOJ_1610_[Usaco2008_Feb]_Line连线游戏_(计算几何基础+暴力)
描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1610 给出n个点,问两两确定的直线中,斜率不同的共有多少条. 分析 暴力枚举直线,算出来斜率放 ...
- 【转】JNI学习积累之一 ---- 常用函数大全
原文网址:http://blog.csdn.net/qinjuning/article/details/7595104 本文原创,转载请注明出处:http://blog.csdn.net/qinjun ...