IOS & #39; nsinternalinconsistencyexception& #39;

Source: Internet
Author: User

Today I want to write a request for the weather. Good. Don't say much nonsense. Paste the code First:

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

Translation is not enough to meet urlstring. The request address is wrong when possible. But the request address is correct. The return is a string of JSON data. Then I got confused, and then I found out that the number of references in this URL was directly written.

, and then parameters the place to put the number of references. Then I wrote the number in separate. It's done.


[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 number of references here must be written in the parameters, otherwise the & symbols in the link. Doesn't seem to recognize it!



IOS & #39; nsinternalinconsistencyexception& #39;

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.