How to get path to a subfolder in main bundle?

后端 未结 3 443
Happy的楠姐
Happy的楠姐 2020-12-19 00:53

I have a project which I am migrating from Obj-C to Swift 3.0 (and I am quite a noob in Swift).

How do I translate this line?

NSString *folder = [[[N         


        
3条回答
  •  庸人自扰
    2020-12-19 01:27

    You can do something like this:

    let folderURL = resourceURL(to: "myfolder")
    
    func resourceURL(to path: String) -> URL? {
        return URL(string: path, relativeTo: Bundle.main.resourceURL)
    }
    

提交回复
热议问题