Skip to content
This repository has been archived by the owner on Mar 22, 2019. It is now read-only.

Escaping URL String #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion OpenWeatherMapAPI/OpenWeatherMapAPI/OWMWeatherAPI.m
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,10 @@ - (void) callMethod:(NSString *) method withCallback:( void (^)( NSError* error,
}

NSString *urlString = [NSString stringWithFormat:@"%@%@%@&APPID=%@%@", _baseURL, _apiVersion, method, _apiKey, langString];
// Please note, we must escape any spaces or other unexpected chars
NSString *escapedUrlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

NSURL *url = [NSURL URLWithString:urlString];
NSURL *url = [NSURL URLWithString:escapedUrlString];

NSURLRequest *request = [NSURLRequest requestWithURL:url];

Expand Down