gpt4 book ai didi

ios - NSURLConnection 在某些参数中返回 Null

转载 作者:行者123 更新时间:2023-11-28 18:20:55 24 4
gpt4 key购买 nike

这是 my URL .我需要从这个 URL 获取数据..它将返回英文单词的值..但是如果我给出像“Para Qué Volviste”这样的参数..然后它返回 null..请帮助我..

我的代码是

 NSURLConnection * connectionGetISRC=[[NSURLConnection alloc]initWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://ws.spotify.com/search/1/track.json?q=Para Qué Volviste"]] delegate:self];
[connectionGetISRC start];


-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
dataJson=[NSMutableData data];
}

-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
NSLog(@"dat %@",data);
[dataJson appendData:data];
}

-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
NSLog(@"error %@",error.description);
[hud hide:YES];
}

-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
id dict=[NSJSONSerialization JSONObjectWithData:dataJson options:kNilOptions error:nil];
NSLog(@"dataJson %@",dataJson);
NSLog(@"dicvt %@",dict);
}

最佳答案

您的 URL 中的空格看起来有问题。试试这个连接字符串

 NSString *str=[NSString stringWithFormat:@"http://ws.spotify.com/search/1/track.json?q=Para Qué Volviste"];
str=[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURLConnection * connectionGetISRC=[[NSURLConnection alloc]initWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]] delegate:self];
[connectionGetISRC start];

关于ios - NSURLConnection 在某些参数中返回 Null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20867243/

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