swift3.0读取Bundle的文件

需要注意的是swift3.0 NSBundle变成了Bundle。

OC

NSDictionary *dic = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:urlString ofType:nil]];

urlString为文件名

swift3.0

        let urlPath = Bundle.main.url(forResource: "WTKData", withExtension: nil)
        let dic = NSDictionary.init(contentsOf: urlPath!)
        print(dic!)

你可能感兴趣的:(swift3.0读取Bundle的文件)