4
imageData=[NSData dataWithContentsOfURL:self.pdfFileUrl options:NSDataReadingMappedAlways error:&error];
NSLog(@"%@",[error localizedDescription]);
NSLog(@"%@",imageData);

in above code I get the error "The file “bg.png” couldn’t be opened because you don’t have permission to view it."

I can't convert bg.png file to NSData.

Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140
Sarthak Patel
  • 129
  • 2
  • 8
  • I have found the solution of this problem!. This is giving error because we directly fetch file with url which in mac directory.But instead of access this file directly, get file url by opening panel for selecting the file. Means getting file path with opening panel is one kind of asking permission of accessing file and its working fine. thanks. – Sarthak Patel Sep 25 '14 at 11:10
  • Do you use any third party library for solve the above issue? I m facing the same problem and used SSL in app. Please share your comment. – Nikunj Jadav Jul 04 '17 at 07:44
  • Possible duplicate of [iOS 9 read file permission](https://stackoverflow.com/questions/33478142/ios-9-read-file-permission) – Cœur Jul 12 '17 at 04:23

1 Answers1

-2

I encountered the same problem. What I did was to go to Build Options. Then I changed the value of the "Compiler for C/C++/Objective-C" to Default Compiler. Its work fine for me