Debugging UIImage未写入或显示在桌面上

Debugging UIImage未写入或显示在桌面上,debugging,uiimage,nsdata,Debugging,Uiimage,Nsdata,无论出于什么原因,我都不会让UIImage出现在我的桌面上。我使用这段代码作为调试的手段。但是,我很确定我正在接收一个映像,因为调试器中的UIImage不是空的 UIImage *imgageProfile = [UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithStri

无论出于什么原因,我都不会让UIImage出现在我的桌面上。我使用这段代码作为调试的手段。但是,我很确定我正在接收一个映像,因为调试器中的UIImage不是空的

UIImage *imgageProfile = [UIImage imageWithData:
                                   [NSData dataWithContentsOfURL:
                                    [NSURL URLWithString: sUrlPic]]];


            // Use this code to debug images
            NSURL *aLocalURL = [NSURL URLWithString:@"file:///Users/snuffles753/Desktop/"];
            NSData *imageData = UIImagePNGRepresentation(imgageProfile);
            [imageData writeToURL:aLocalURL atomically:YES];

-[NSData writeToURL:…]
获取包含要创建的文件名的URL。它将`获取文件夹的URL,并在其中自动创建一个文件。因此,您当前的代码试图覆盖现有目录,但失败了

而是显式指定文件名:

NSURL *aLocalURL = [NSURL URLWithString:@"file:///Users/snuffles753/Desktop/debug.png"];