I'm really confused on this one. There are dozens of questions around the web asking "How do I get info from my plist file in Swift?" and the same answer is posted everywhere:
let path = NSBundle.mainBundle().pathForResource("Config", ofType: "plist")
However, this line produces always produces nil
for me. I have replaced Config
with other components found in the default plist file, but get nil
as well.
I am trying to access my custom ProductIdentifiers
Array like so:
let url = NSBundle.mainBundle().URLForResource("ProductIdentifiers", withExtension: "plist")!
var productArray = NSArray(contentsOfURL: url) as! [[String:AnyObject!]]
I get a crash stating fatal error: unexpectedly found nil while unwrapping an Optional value
on productArray. I have also tried this with other default plist values in place of ProductIdentifiers
.
Does anyone know why this is not working for me even though there are so many posts around of people using this successfully?