2

I am creating a sample application where it downloads 100 images from server and stores it in iPad.

In XCode, I am using the NSURL to retrieve the image file and using NSData to save it into my local folder. I am able to save the images in my mac air desktop folder. But I want my application to be deployed in iPad. So here is my question:

  • Where do I store the file in my iPad, so that my application can retrieve the images when needed?

  • If possible can someone give me the code for saving the images in your iPad resource directory (or whatever directory needed). Just the code where you build the path will do good.

I know this is kind of a basic question, since I am new to objective-C, I am kind of struggling with it.

2 Answers 2

2

Here is an example function how to retrieve the applications documents folder. In there you can create your own folder structure. This folder is also backed up by iTunes and will be preserved when doing application updates.

NSString* GetApplicationDocumentsDirectory() {
    static NSString* documentsDirectory = nil;
    if (documentsDirectory == nil) {
    documentsDirectory = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
                                                               NSUserDomainMask,
                                                               YES)
                          objectAtIndex:0] retain];
    }
    return documentsDirectory;
}
0
-1

In my humble opinion, using a Core Data store would be the best approach for this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.