Ios 从服务器获取数据,NSURLConnection显示在TableView中
我快死了,请帮帮我Ios 从服务器获取数据,NSURLConnection显示在TableView中,ios,ios7,get,nsurlconnection,Ios,Ios7,Get,Nsurlconnection,我快死了,请帮帮我 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:urlSt
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");
}
检查以下代码:
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");
}
我想发送扫描码Sitring是{123,UK111,IND111,USA111,}不确定这是否会产生影响,但您不需要NSString stringWithFormat中的花括号{},您可以这样离开:
NSString*urlString=[NSString stringWithFormat:@”http://1-dot-digiphoto-01.appspot.com/v1/service/rest/getAlbums/QR/%@“,扫描码]代码>@Chenna检查我的答案。它起作用了now@urnotsam我们可以用花括号表示查询字符串。他错过了发送内容模式。一旦他设置了内容模式,如下面我的答案,它一定会工作。@PREMKUMAR你是对的,我的错。你下面的答案是正确的,我会投票给其他有类似问题的人