Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

GOA

macrumors newbie
Original poster
Jun 30, 2014
13
1
Hello,

I am having a bit of a difficulty understanding the error situation. Here is the code:

Code:
NSURL *imageURL = [NSURL URLWithString:@"/Users/GOA/Desktop/present.png"];

NSError* error = nil;


NSData* data = [[NSData alloc] init];


data = [NSData dataWithContentsOfURL:imageURL options:NSDataReadingUncached error:&error];


if (error) {
                         NSLog(@"%@", [error localizedDescription]);
                         }
               else 
                         {
                         NSLog(@"Data has loaded successfully.");
                         }
UIImage *image = [UIImage imageWithData:imageData];

The imageData remains nil.

The 'data' returns following error message:

The operation couldn’t be completed. (Cocoa error 256.)

What am I doing wrong and whats' the fix please ?

Thank you.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.