Question

all:

In my developed app,I wrongly delete the documents folder when user do some action.

But my app is in the App Store. How can i reproduce the documents folder in the next update version?

When updated to the next version, will the documents folder will be created by ios automatically? Or I must recreate the folder in code? Can documents folder created by code?

==============================================

hi,all:

Thank you for you help.I find even if i delete the documents folder of the app, when updating the app to the new version,iOS will creat the folder automatically.But if in the root folder of the app, there is a file with name "documents",the documents folder will not be created automatically(But only in jailbreaked mobile ,you can creat file in the root of the app).So this may be a bug of iOS.

Was it helpful?

Solution

When updated to the next version, will the documents folder will be created by ios automatically? Or I must recreate the folder in code? Can documents folder created by code?

No, it will not be created automatically. You should create this folder:

- (void) createFolderDocumentIfNotExisted
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
NSFileManager *fm = [NSFileManager defaultManager];
if(![fm fileExistsAtPath:basePath]){
    NSError *err;
    [fm createDirectoryAtPath:basePath withIntermediateDirectories:NO attributes:nil error:&err];
}
}

OTHER TIPS

set param 2 to YES .

 - (BOOL)createDirectoryAtURL:(NSURL *)url 
withIntermediateDirectories:(BOOL)createIntermediates 
attributes:(NSDictionary *)attributes error:(NSError **)error NS_AVAILABLE(10_7, 5_0);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top