【发布时间】:2014-11-24 01:17:15
【问题描述】:
我有这个代码到图像的 url,我的 url 没有什么问题,它包含 \u 和 xcode 认为它是特殊字符所以我通过在我的 url 中添加 \u 来逃避它 但是当我通过它时
fullPath = [NSString stringWithFormat:@"http:\\www.school-link.net\\uploads\\%@",image_url];
NSLog(@"file path %@",fullPath);
//i try escape space by this code it dosnt work
//fullPath = [fullPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [[NSURL alloc]initWithString:fullPath];
NSURLRequest *request = [[NSURLRequest alloc]initWithURL:url];
AFHTTPRequestOperation *posterOperation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
posterOperation.responseSerializer = [AFImageResponseSerializer serializer];
[posterOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Response: %@", responseObject);
image_view.image = responseObject;
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Image request failed with error: %@", error);
}];
[[NSOperationQueue mainQueue] addOperation:posterOperation];
[posterOperation start];
它给我错误,任何想法 谢谢大家
图像请求失败并出现错误:Error Domain=NSURLErrorDomain Code=-1000 "bad URL" UserInfo=0x8f9f900 {NSUnderlyingError=0x9a94cf0 "bad URL", NSLocalizedDescription=bad URL}
【问题讨论】:
标签: ios afnetworking nsurl