how to place a file in application sand box in iphone
Is there any way of placing a file into applicatio开发者_运维技巧n "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.
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];
精彩评论