mainbundle

Swift 3 - Copy Folder w/ contents from Main Bundle to Documents Directory

大兔子大兔子 提交于 2019-12-10 02:45:07
问题 I have folders with files inside them in my main bundle, and I want to copy/cut them to the Documents Directory at first launch of the application to access them from there. I've seen examples but they're all in Obj-C and I'm using Swift 3. How can I do this? 回答1: I managed to do it using 2 functions: func copyFolders() { let filemgr = FileManager.default filemgr.delegate = self let dirPaths = filemgr.urls(for: .documentDirectory, in: .userDomainMask) let docsURL = dirPaths[0] let folderPath

Unable to play MP4 video file from mainBundle

狂风中的少年 提交于 2019-11-28 23:05:21
So I'm trying to play a simple intro animation video file that I've dragged into my project in XCode and therefore should be able to play from my mainBundle, right? With this code: NSURL *urlString = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"introvideo" ofType:@"mp4"]]; MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:urlString]; [player play]; I get this error message: * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSURL initFileURLWithPath:]: nil string parameter' Any help would be great! This

Unable to play MP4 video file from mainBundle

时光总嘲笑我的痴心妄想 提交于 2019-11-27 14:31:31
问题 So I'm trying to play a simple intro animation video file that I've dragged into my project in XCode and therefore should be able to play from my mainBundle, right? With this code: NSURL *urlString = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"introvideo" ofType:@"mp4"]]; MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:urlString]; [player play]; I get this error message: * Terminating app due to uncaught exception