Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS NSBundle get all files within group in project file structure

Tags:

ios

swift

I'm fairly new to swift but I'm trying to access a folder's content that I've put in a "Resources" group folder WHILE using the path as a NSURL. I was thinking of using "fileURLWithPath" But I'm not entirely too sure. Here is the file path /Users/userName/Desktop/myapp/myapp/Resources/

like image 884
Michael Giacomo Avatar asked Oct 18 '22 05:10

Michael Giacomo


1 Answers

In run time, app will use its own data container, not your Desktop.

/Users/userName/Library/Developer/CoreSimulator/Devices/.../data/Containers/Bundle/Application/.../YourAppName.app

So, you have to copy the files into your project. And you can get your file this way ..

// Swift 3
let files = Bundle.main.paths(forResourcesOfType: "mov", inDirectory: nil)
print(files.count)
like image 98
Willjay Avatar answered Nov 01 '22 18:11

Willjay