This question already has an answer here:
- Swift - How do I get the file path inside a folder 1 answer
I created a directory underneath my main project folder in XCode named Sounds
.
I then dragged 8 audio files of type wav
into the Sounds
folder.
I ensured to check Copy items if needed
when prompted by the dialog.
I'm currently attempting to retrieve a list of all wav
files located in the Sounds
directory.
I've attempted this a number of different ways, but below is the most recent.
Bundle.main.paths(forResourcesOfType: "wav", inDirectory: "Sounds")
The above code, as well as my other attempts have either yielded nil
or an empty array.
So my question is, how can I retrieve a list of all files of type wav
from the Sounds
directory?
Furthermore, I'm a little unclear on the iOS directory structure.
For example, whats the different between the directory listings located in Bundle.main
and the DocumentDirectory
?
I have edited my question as I incorrectly implied that Sounds
folder was located in the root directory.