gpt4 book ai didi

ios - NSCFString absoluteURL 异常

转载 作者:可可西里 更新时间:2023-11-01 06:19:38 26 4
gpt4 key购买 nike

这是我使用 JSON 从 MySQL 表中检索数据的代码:

//URL definition where php file is hosted

int categoriaID = [[categoriaDescription objectForKey:@"idCategoria"] intValue];

NSString *string = [NSString stringWithFormat:@"%d", categoriaID];
NSLog(@"CATEGORIA ID STRING %@",string);
NSMutableString *ms = [[NSMutableString alloc] initWithString:@"http://mujercanariasigloxxi.appgestion.eu/app_php_files/categoriaslist.php?id="];
[ms appendString:string];
// URL request
NSLog(@"URL = %@",ms);
NSURLRequest *request = [NSURLRequest requestWithURL:ms];
//URL connection to the internet
[[NSURLConnection alloc]initWithRequest:request delegate:self];

记录的 URL 是正确的,但应用程序抛出异常:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString absoluteURL]: unrecognized selector sent to instance 

我猜错误应该在上面的代码中,但我不明白为什么。欢迎任何帮助。

最佳答案

我认为您的代码有误。

NSURLRequest *request = [NSURLRequest requestWithURL:ms];

应该改为:

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:ms]];

关于ios - NSCFString absoluteURL 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21977521/

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