surajbaba
surajbaba

Reputation: 3

how to place a file in application sand box in iphone

Is there any way of placing a file into application "sandbox" i.e into eg:

/var/mobile/Applications/30B51836-D2DD-43AA-BCB4-9D4DADFED6A2/Documents

of iphone?

My Application expects a file to be put into /Documents folder of application so that it can be uploaded to my local server.

This method should confirm to the rules of Apple so that it should not be rejected.

Upvotes: 0

Views: 123

Answers (1)

Hoang Pham
Hoang Pham

Reputation: 6949

Why rejected? It is definitely normal to save a file to a Documents folder and Apple can not reject your application just because you save a file to the application Documents folder.

Use the following code to do so:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
NSString *pathToFile = [basePath stringByAppendingPathComponent:@"somefile.format"];
[someNSData writeToFile:pathToFile atomically: YES];

Upvotes: 0

Related Questions