2
這是我的代碼使用JSON來從一個MySQL表中的數據:NSCFString absoluteURL例外
//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];
記錄的網址是正確的,但應用程序將引發異常:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString absoluteURL]: unrecognized selector sent to instance
我猜錯誤應該在上面的代碼中,但我不明白爲什麼。歡迎任何幫助。
是的,你是對的,謝謝@TanVu。 – mvasco