gpt4 book ai didi

ios - 使用在 TableView 中显示的 NSURLConnection 从服务器获取数据

转载 作者:行者123 更新时间:2023-11-29 12:38:22 25 4
gpt4 key购买 nike

我收到 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");

}

最佳答案

检查下面的代码:

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");
}

关于ios - 使用在 TableView 中显示的 NSURLConnection 从服务器获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25665194/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com