Q:

load data from cache with NSURL doesn't work

i'm trying to load a photo from my cache directory.
this is the code where i write the photo into a cache folder:
+(BOOL)writeAData:(NSData *)imageData atURL:(NSURL *)fileUrl
{
    return [imageData writeToURL:fileUrl atomically:YES];
}

this code works fine, but i have problems when i try to load the code from the cache folders:
i use the method initWithContentsOfURL inside a block:
     NSData *imageData = [[NSData alloc] initWithContentsOfURL:self.imageUrl];

this is the format of url
file://localhost/Users/MarcoMignano/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/0E8E54D8-9634-41CF-934B-A7315411F12F/Library/Caches/image_cache/Meyer%20Library.jpg

the URL is correct, but when i try to use the method above i get this error:
 ..... [__NSCFString isFileURL]: unrecognized selector sent to instance 0x8a0c5b0 .....

that is the code when i take the url of my model:
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    self.photos = [PhotoAlreadyDisplayed getAllPicture];
}

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([sender isKindOfClass:[UITableViewCell class]]) {
        NSIndexPath *indexPath = [self.tableView indexPathForCell:sender];
        if (indexPath) {
            if ([segue.identifier isEqualToString:@"Show Image"]) {
                if ([segue.destinationViewController respondsToSelector:@selector(setImageUrl:)]) {
                    NSURL *url = [[self.photos objectAtIndex:indexPath.row] valueForKey:@"url"];
                    [segue.destinationViewController performSelector:@selector(setImageUrl:) withObject:url];
                    [segue.destinationViewController setTitle:[self titleForRow:indexPath.row]];
                }
            }
        }
    }
}

whats wrong with the URL? how can i fix it? thank you
i have find the solution:
when i load the url for the model, i need to initialize the url using fileURLWithPath method:
NSURL *url =  [NSURL fileURLWithPath:[[self.photos objectAtIndex:indexPath.row] valueForKey:@"url"]];

Now all works fine, thank you so much for yours help

A:

solution: when i load the url for the model, i need to initialize the url using fileURLWithPath method:
NSURL *url =  [NSURL fileURLWithPath:[[self.photos objectAtIndex:indexPath.row] valueForKey:@"url"]];

Now all works fine, thank you so much for yours help

