Files
public class Files
                Utilities to read files out of the applicaton’s bundle.
- 
                  
                  
Loads a file stored in the app’s bundles. It will search each bundle, returning contents of the first matching file. Failures will report an error through a modal alert.
Declaration
Swift
public static func loadFile(named: String) -> String?Parameters
namedThe name of the file to load
Return Value
The contents of the file as a string, or Nil if the file does not exist.
 - 
                  
                  
Prompts the user to select a file from the app bundle that has the desired extension (eg:
json,txt, etc.). Theactionfunction is called with the name and contents of the selected file if one is chosen. Failures will report an error through a modal alert.Usage (inside a ViewController):
Files.chooseFile(withExtension: "json", forController: self, action: { (fileName: String, contents: String) in ... } )or with trailing closure notation:
Files.chooseFile(withExtension: "json", forController: self) { (fileName: String, contents: String) in ... }Declaration
Swift
static public func chooseFile(withExtension: String, forController controller: UIViewController, action : @escaping (_ fileName: String, _ contents: String) -> Void)Parameters
withExtensionExtension of all files in bundle to chose from. eg:
.json
,.txt
, …forControllerthe UIViewController initiating the request.
actionThe function to call when the user chooses a file. It is passed the name and contents of the chosen file.
fileNamethe name of the chosen file.
contentsthe contents of the chosen file as a string.
 
        Files Class Reference