NSCocoaErrorDomain Code = 256
means:
A file system or file I/O related error whose reason is unknown.
Simply, it tells us nothing.
However in general, NSData
's dataWithContentsOfURL
should only be use to access local file resources.
Important: Do not use this synchronous method to request network-based URLs. For network-based URLs, this method can block the current thread for tens of seconds on a slow network, resulting in a poor user experience, and in iOS, may cause your app to be terminated.
You can try improving your code and use a better way of downloading data. It might fix the issue you are experiencing. Instead of using dataWithContentsOfURL
, you can use NSURLConnection
's class methods like:
+ (void)sendAsynchronousRequest:(NSURLRequest *)request
queue:(NSOperationQueue *)queue
completionHandler:(void (^)(NSURLResponse*, NSData*, NSError*))handler;
Based on: