Getting a list of files in the Resources folder - iOS

前端 未结 7 2227
悲哀的现实
悲哀的现实 2020-11-28 19:52

Let\'s say I have a folder in my \"Resources\" folder of my iPhone application called \"Documents\".

Is there a way that I can get an array or some type of list of a

7条回答
  •  死守一世寂寞
    2020-11-28 20:41

    Swift 4:

    If you have to do with subdirs "Relative to project" (blue folders) you could write:

    func getAllPListFrom(_ subdir:String)->[URL]? {
        guard let fURL = Bundle.main.urls(forResourcesWithExtension: "plist", subdirectory: subdir) else { return nil }
        return fURL
    }
    

    Usage:

    if let myURLs = getAllPListFrom("myPrivateFolder/Lists") {
       // your code..
    }
    

提交回复
热议问题