Graham Bell
Graham Bell

Reputation: 1149

How to copy a file from Documents Directory to application bundle?

Hi in my app launch i will invoke a web-service call and i will download some zip files now i need to save those files permanently in my application bundle so that when i launch my app for the second time i will just look for update if there is no update i will just use my previously saved files, so i thought to make use of document directory and get the zip file then unzip it and save it in application bundle, here my problem is how to save a file from DocumentsDirectory to my Application Bundle? and does my approach is right & efficient way or do i need to follow some other ways to achieve this? Any help is thankful in advance.

Upvotes: 1

Views: 371

Answers (2)

Apurv
Apurv

Reputation: 17186

The resources which are modified at runtime should be part of Documents directory. iPhone application creates a sandbox environment which is signed. If you try to modify any of the bundle resource or try to add/remove the resource, it will not allow. It works fine with simulator but not with device.

So you should store your response to the documents directory and not to the bundle.

Upvotes: 4

Jonathan King
Jonathan King

Reputation: 1528

You can't write to your application's bundle - it is readonly, only the documents directory is readwrite.

You don't need to move the files, as the documents directory provides permanent storage.

Upvotes: 4

Related Questions