Directory Changes in iOS8

1 Seperate the bundle and sandbox directory, and each time you run the app, the uuid will be changed in both path, bellow demo shows document, home and main bundle

2014-09-29 22:53:15.060 HelloWorld[993:157357] /var/mobile/Containers/Data/Application/9B0DF5DF-0009-4197-9286-085391FB27D3/Documents

2014-09-29 22:53:15.062 HelloWorld[993:157357] /var/mobile/Containers/Data/Application/9B0DF5DF-0009-4197-9286-085391FB27D3

2014-09-29 22:53:15.062 HelloWorld[993:157357] /private/var/mobile/Containers/Bundle/Application/DDCCC2B2-0BDA-4E93-85AB-C7374136039E/HelloWorld.app

 

2 XCode will get exception while webview try to read a PDF in main bundle,  and show an error:

DiskImageCache: Could not resolve the absolute path of the old directory.

But app won't crash, some message said change loadData to loadRequest, but it don't work, no solution found now.

    NSString *documentsDirectory = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"pdf"];

//    NSData *data = [NSData dataWithContentsOfFile:documentsDirectory];

//    NSData *data = [NSData dataWithContentsOfURL:[NSURL fileURLWithPath:documentsDirectory]];

//    NSString *sMimeType = @"application/pdf";

    

    UIWebView *webView = [[UIWebView alloc] initWithFrame:self.view.bounds];

    [self.view addSubview:webView];

//    [webView loadData:data MIMEType:sMimeType textEncodingName:@"utf-8" baseURL:nil];

 

    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:documentsDirectory]]];

 

 

你可能感兴趣的:(Directory)