简体   繁体   中英

Retrieving NSURL from NSUserDefault

我已将路径NSURL作为NSString存储到NSUserDefault同时从NSUserDefault检索NSUrl ,我得到NSURL路径,如"file:///var/mobile/Containers/Data/Application/EB2E7DCD-5B73-4B0B-9BC5-6758AF75C68C/Documents/FinalVideo-958.mov"但视频正在从这个链接显示....上面的路径来自 iphone 设备

Always use relative path same like below code.

NSArray *paths =   NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];

NSString *myPathDocs =  [documentsDirectory stringByAppendingPathComponent:@"FinalVideo-958.mov"];

if ([[NSFileManager defaultManager] fileExistsAtPath:myPathDocs])
{
   NSLog(@"video file found.");
}       

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM