Reputation: 10095
If I have a group in a project called 'sounds', how can I create an array from files in that group? I think this is probably not quite the same as looking in a physical path on disk.
I tried the following:
var docsPath = NSBundle.mainBundle().resourcePath! + "/sounds";
let fileManager = NSFileManager.defaultManager()
var error: NSError?
var docsArray = fileManager.contentsOfDirectoryAtPath(docsPath, error:&error)
println(docsArray) // outputs nil
The sounds are not in a physical folder on disk but is there a method to address the group by name?
The group was created by right-clicking the project tree and selecting 'New Group'
Upvotes: 0
Views: 244
Reputation: 285140
In Xcode the yellow folders are virtual folders without an equivalent in the file system. To create a real (blue) folder drag a folder containing the sound files into the project tree and select "Create folder references" in the dialog window.
To append a path component to a path I'd recommend to use the designated method
let docsPath = NSBundle.mainBundle().resourcePath!.stringByAppendingPathComponent("sounds")
Upvotes: 1