I've looked this up but the answer always seems to be specific to that problem.
I'm trying to request info from a web server using JSON and have the info come up onto a table view. The code that is giving me trouble is below:
CalendarCommunicator.m:
#import "CalendarCommunicator.h"
#import "CalendarCommDelegate.h"
@implementation CalendarCommunicator
- (void)searchGroupsAtCoordinate:(CLLocationCoordinate2D)coordinate
{
NSString *urlAsString = [NSString stringWithFormat:@"http://medpak.costarica.com/api/content/render/false/type/json/query/+structureName:calendarEvent%20+(conhost:9fe93d82-1cd8-46b1-9dda-8b940e407d23%20fonhost:SYSTEM_HOST)%20+languageId:1", coordinate.latitude, coordinate.longitude];
NSURL *url = [[NSURL alloc] initWithString:urlAsString];
NSLog(@"%@", urlAsString);
[NSURLConnection sendAsynchronousRequest:[[NSURLRequest alloc] initWithURL:url] queue:[[NSOperationQueue alloc] init] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
if (error) {
[self.delegate fetchingGroupsFailedwithError:error];
} else {
[self.delegate recievedGroupsJSON:data];
}
}];
}
@end
In the NSString *urlAsString section I get a warning with the URL. It says '"Invalid Conversion Specifier '+'". What exactly does this mean? Are there to many '+' signs in the URL or am I missing something?
The reason is that % has meaning both to percent-encoding of URLs and also to format strings. In this case +stringWithFormat sees the %20+ in your string, and thinks you're giving it a format command. For literal % in your URL format string, make them %%, that is, pass %% to string formatting methods / functions to get a literal %.
However, in your particular case, I'm not sure which ones you're trying to substitute for the locations and which ones you're meaning to stand as percent-escapes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With