1

What is the correct way to store large images on iOS, where "large" means > 1MB?

Also, I want to prevent the user having the ability to access them via some kind of hacking.

jscs
  • 63,694
  • 13
  • 151
  • 195
Thizzer
  • 16,153
  • 28
  • 98
  • 139

1 Answers1

2

You can write the image to documents directory of your app and the paths for the images in coreData or NSUserDefaults. To prevent hacking you can encrypt the data before writing it to documents directory. For encryption look at this post.

Edit:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0]; 
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"yourFileNameAndExtension"];

Then just use the "path" NSString.

Community
  • 1
  • 1
Alex Terente
  • 12,006
  • 5
  • 51
  • 71
  • If I use NSData's writeToFile, will it automatically write the filename to the apps document directory? i.e. using [data writeToFile:@"test.enc" atomically:NO] were will test.enc be placed? – Thizzer May 03 '11 at 12:29
  • You need to specify the path to the documents directory. I will edit my post. – Alex Terente May 03 '11 at 12:30