我正在尝试从URL创建一个字符串,但URL为null。该字符串确实包含一些内容,但URL仍为空。
以下是我创建网址的位置:
NSData *stringData = feed.urlString;
NSString *stringForURL = [[NSString alloc] initWithData:stringData encoding:NSUTF8StringEncoding];
NSLog(@"Here is the string before being turned into a URL: %@", stringForURL);
NSURL *finalURL = [[NSURL alloc] initWithString:[stringForURL stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]];
finalURL = details.finalURL;
NSLog(@"Here is the final URL: %@", finalURL);
答案 0 :(得分:0)
将您的最终网址代码更改为: -
Nstring *finalURL = [NSURL URLWithString:
[stringForURL
stringByAddingPercentEscapesUsingEncoding:
NSUTF8StringEncoding]];