Приложение закрывается при использовании NSURL с параметрами
В моем приложении я отправил запрос в мой файл PHP, чтобы загрузить некоторую информацию. Всякий раз, когда я использую код ниже, он прекращается:
-(void)downloadItems
{
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSString *myString = [prefs stringForKey:@"commentsId"];
NSLog(@"The comments id is : %@",myString);
// Download the json file
NSString *urlstring = [NSString stringWithFormat:@"http:/MyWebSite.com/checkphp.php?title=%@", myString];
NSURL *jsonFileUrl = [NSURL URLWithString:urlstring];
NSLog(@"The qasida id is: %@", jsonFileUrl);
// Create the request
NSURLRequest *urlRequest = [[NSURLRequest alloc] initWithURL:jsonFileUrl];
// Create the NSURLConnection
[NSURLConnection connectionWithRequest:urlRequest delegate:self];
}
Но если я уберу myString
от urlString
как это:
NSURL *jsonFileUrl = [NSURL URLWithString:@"http:/myWebSite/checkphp.php?title=%@"];
приложение не прекратит работу и получит данные.
Может кто-нибудь сказать мне, что не так с моим кодом?
Спасибо