Я пытаюсь передать переменную на php-страницу, но она не передается на страницу или не сохраняется в базе данных. См. Комментарии в следующем коде:Отправка переменных в php из объекта C Cocoa
NSString *[email protected]"fname";
NSString *[email protected]"lname";
NSString *urlString = [[NSString alloc] initWithFormat:@"http://localhost:8888/Test-objective%20c%20/send.php?first_name=%@&last_name=%@",fname,lname];
NSLog(urlString);
NSURL *url = [ NSURL URLWithString:urlString];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
NSAlert *dq= [[NSAlert alloc] init];
[dq setMessageText:urlString];
[dq runModal];
[request setHTTPMethod:@"GET"];
NSURLConnection* connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
[connection start];
NSAlert *d= [[NSAlert alloc] init];
[d setMessageText:@"connection"];
[d runModal];
//This is the part I don't understand.
//This line has a problem:
NSString *urlString = [[NSString alloc] initWithFormat:@"http://localhost:8888/Test-objectivec/send.php?first_name=%@&last_name=%@",fname,lname];
//But when I replace it with
NSString *urlString = @"http://localhost:8888/Test-objectivec/send.php?first_name=My&last_name=nme";
//Then it works just fine.
Кроме того, может ли кто-нибудь сказать мне, как увидеть ответ с сервера?
Измените журнал на 'NSLog (@" строка URL:% @ ", urlString);'. Отладка, все создано? – Wain