Terry
Terry

Reputation: 337

Failed in deleting file in main bundle under sandbox

I am trying to delete a file in the main bundle of my app in code. What I am trying is: get the file path via [[NSBundle mainBundle] pathForResource:ofType:], then try to delete it via [[NSFileManager defaultManager] removeItemAtPath:].

My problem is, my app is sandboxed, so I got information like this: sandboxd deny file-write-unlink ...

Is there a way to overcome this? Any idea would be appreciated.

Upvotes: 1

Views: 749

Answers (1)

trojanfoe
trojanfoe

Reputation: 122391

You cannot delete files in your own sandbox as for one thing it will break the digital signature used to verify the validity of your app.

If you want to have files that can be manipulated in this way then you need to copy them from your bundle into, say, the caches directory, where you can do whatever you like to them.

Upvotes: 1

Related Questions