IOS ' nsinternalinconsistencyexception ', Reason: ' Invalid parameter not satisfying:urlstring '

Source: Internet
Author: User

Today want to write a request for the weather, good, nonsense not much to say, first paste code:

Send GET request using afnetworking, but always error IOS ' nsinternalinconsistencyexception ', Reason: ' Invalid parameter not satisfying: URLString '

The translation is not satisfied with the urlstring, possibly the request address is wrong, but the request address is correct, the return is a string of JSON data, and then I was confused, and then I found that the URL parameter is directly written up

, and then parameters put the parameters of the place did not put, and then I put the parameters in a separate written in, it was done Ah!


[Appdelegate.manager get:@] http://api.map.baidu.com/telematics/v3/weather?location= Nanjing &output=json&ak= 4zg5r7sqnqa "Parameters:nil success:^ (afhttprequestoperation *operation, id responseobject) {NSDictionary *roo            Tdict=responseobject;            NSLog (@ "%@", rootdict);            Nsarray *resultarray = [rootdict objectforkey:@ "Results"];                        Nsdictionary *citydict=[resultarray objectatindex:0];            Get the city nsstring *currentcity= [citydict objectforkey:@ "currentcity"];            Prepare to get the weather nsarray *weatherarray= [citydict objectforkey:@ "Weather_data"];            Get the first day of the weather dictionary nsdictionary *firstdict=[weatherarray objectatindex:0];            Get the first day date nsstring *firstdate=[firstdict objectforkey:@ "Date"];            Get the first day weather nsstring *weather=[firstdict objectforkey:@ "Weather"];            Get the first day wind nsstring *wind=[firstdict objectforkey:@ "winds"]; Get the first day of temperature Nsstring *temper=[firstdict objectforkey:@ "Temperature"]; [[[Uialertview alloc] initwithtitle:[nsstring stringwithformat:@ "Current City%@\n Date:%@\n weather%@\n Wind%@\n temperature%@\n", currentcity,        Firstdate,weather,wind,temper] Message:nil delegate:nil cancelbuttontitle:@ "OK" otherbuttontitles:nil, nil] show];        } failure:^ (Afhttprequestoperation *operation, Nserror *error) {NSLog (@ "link failed");    }]; });

Correct code:

Nsdictionary *[email protected]{@ "location": @ "Nanjing", @ "output": @ "JSON" @ "AK": @ "4zg5r7lw8fd3sqnqa"};        [Appdelegate.manager get:@ "Http://api.map.baidu.com/telematics/v3/weather" Parameters:parameter success:^ ( Afhttprequestoperation *operation, id responseobject) {

The parameters here must be written again parameters, or the links in those & symbols, as if not recognized!



IOS ' nsinternalinconsistencyexception ', Reason: ' Invalid parameter not satisfying:urlstring '

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.