I am tring to get the NSData
from a local file using [NSData dataWithContentsOfURL:]
but am getting nil
even when the fileSize
returned by [NSFileManager defaultManager]
is a positive integer.
Surprisingly, I got this issue when the base sdk was increased from iOS 7 to iOS 8.
I am not sure whether it is an
iOS
bug or what as it worked iniOS 7
base SDK and not withiOS 8
, but here is the solution I found after wasting a couple of hours debugging the code :-(Use
[NSData dataWithContentsOfFile:(NSString *)]
instead ofdataWithContentsOfURL