如何编码HTTP GET请求

时间:2013-12-26 20:46:59

标签: objective-c ios7 xcode5

好的,所以我有以下代码,我目前将用于获取响应。我知道我需要对该响应进行编码以及将其设置为新的NSString变量(因为我想将响应用于逻辑),我该怎么做?

NSLog(@"textField *UserEmail did end editing");

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"*will have url here*"] cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:10];
[request setHTTPMethod:@"GET"];

NSError *requestError;
NSURLResponse *urlResponse = nil;

NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&requestError];

NSLog(response);

1 个答案:

答案 0 :(得分:1)

试试这个:

NSString *result = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];

干杯:)