Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 为什么要将字符和前斜杠附加到我的NSURL中?_Ios_Cocoa_Nsurl - Fatal编程技术网

Ios 为什么要将字符和前斜杠附加到我的NSURL中?

Ios 为什么要将字符和前斜杠附加到我的NSURL中?,ios,cocoa,nsurl,Ios,Cocoa,Nsurl,我的图像不是从它们的URL加载的。当我记录NSURL时,它看起来是正确的 my.website.com/images/image1.png 但是当我设置断点时,NSURL在调试器控制台中显示为 my.website.com/images/image1.png\x05\b 我已经通过我的web浏览器检查了json,它是完全有效的。字符串以“png”的“g”结尾 我正在使用SDWebImage异步加载表格单元格的图像。用于图片的URL来自一个编码JSON的php文件 - (UITableViewCe

我的图像不是从它们的URL加载的。当我记录NSURL时,它看起来是正确的

my.website.com/images/image1.png

但是当我设置断点时,NSURL在调试器控制台中显示为

my.website.com/images/image1.png\x05\b

我已经通过我的web浏览器检查了json,它是完全有效的。字符串以“png”的“g”结尾

我正在使用SDWebImage异步加载表格单元格的图像。用于图片的URL来自一个编码JSON的php文件

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    SpotsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SpotCell" forIndexPath:indexPath];

    NSInteger row = indexPath.row;

    if (self.spotDictionary)
    {
        NSDictionary* spot = (NSDictionary*)[self.spotDictionary objectForKey:[NSString stringWithFormat:@"%d", row]];
        NSString* title = [spot objectForKey:@"Title"];
        NSURL* imageURL = [NSURL URLWithString:(NSString*)[spot objectForKey:@"Image"]]; NSLog(@"%@", imageURL);
        UIImage* placeholder = [UIImage imageNamed:@"placeholder.png"];

        // See ~*~ below
        NSURL* testURL = [NSURL URLWithString:@"http://www.hdwallpaperspot.com/wp-content/uploads/2013/08/Volvo-station-wagon-612pb.jpg"];

        cell.nameLabel.text = title;

        [cell.pictureView setImageWithURL:imageURL
                         placeholderImage:placeholder]; // SDWebImage category for UIImage

//breakpoint here
    }

    return cell;
}
~*~
为了确保SDWebImage正确运行,我从网络上抓取了一个图像来临时测试该库,它的运行非常出色。我已经检查了
“Image”
对象的类,它是
\NSCFString
。添加了
(NSString*)
转换,以防我对NSCFString和NSString之间互换性的理解有缺陷。不走运

这很尴尬,但我会分享我的错误,这样就不会有人误解了

我忘记在我的
Image
JSON对象中指定协议(http://)。 我认为NSURL类将具有某种默认HTTP检查,但我意识到这是不可行的,因为有其他协议可以与NSURL一起使用


感谢@rmaddy指出调试器,嗯,bug

这是一个调试器问题。搜索,您将找到报告此问题的其他人。在调试器命令行中键入
po imageURL
,您将看到预期的值。是的,您是正确的。但是图像仍不会从
imageURL
加载。然而,它们将从
testURL
中删除。URL是完全有效的,我可以将它从日志控制台复制出来,粘贴到Firefox中,然后加载。所以我忍不住觉得这些奇怪的角色还在做伏都教。