我收到didFailWithError请帮帮我
scanCode = @"123";
NSString * urlString=[NSString stringWithFormat:@"http://1-dot-digiphoto-01.appspot.com/v1/service/rest/getAlbums/QR/{%@}",scanCode];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString]];
// Create url connection and fire request
NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];
if (!conn)
{
responseData = nil;
NSLog(@"Connection Error");
}
答案 0 :(得分:1)
检查以下代码:
NSString *urlString = [NSString stringWithFormat:@"http://1-dot-digiphoto-01.appspot.com/v1/service/rest/getAlbums/QR/{%@}",@"123"];
NSURL *url = [NSURL URLWithString:urlString];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
[theRequest addValue: @"application/x-www-form-urlencoded; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest setHTTPMethod:@"GET"];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if( connection )
{
NSLog(@"Success");
}
else
{
NSLog(@"Failed");
}