0

I am trying to get data from a JSON feed. The feed URL needs to be edited by my program so that it has the correct co-ordinates. But I keep on getting the error:

Too many arguments to method call, expected 1, have 3

Here is my code:

NSString *lat = [[NSString alloc] initWithFormat:@"%g", newLocation.coordinate.latitude];
latitude.text = lat;

NSString *lng = [[NSString alloc] initWithFormat:@"%g", newLocation.coordinate.longitude];
longitude.text = lng;

NSString *acc = [[NSString alloc] initWithFormat:@"%g", newLocation.horizontalAccuracy];
accuracy.text = acc;

//

NSURLRequest *theRequest = [NSURLRequest requestWithURL: [NSURL URLWithString:@"http://api.wunderground.com/api/595007cb79ada1b1/geolookup/q/%@,%@.json", lat, lng]];

Thanks, Dan

4

1 回答 1

4

URLWithString不期望格式字符串,因此不期望参数lnglat

尝试首先使用采用格式字符串的构造函数在其他地方创建该字符串:

NSString *urlString = [NSString  stringWithFormat: @"http://api.wunderground.com/api/595007cb79ada1b1/geolookup/q/%@,%@.json", lat, lng];
NSURLRequest *theRequest = [NSURLRequest requestWithURL: [NSURL URLWithString:urlString]]
于 2013-05-13T13:03:23.257 回答