-
-
Save riteshhgupta/0bce24a1ce8a9b93f857fc8cf0e41ba3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension FileManager { | |
static var documentsDirectory: URL { | |
return FileManager | |
.default | |
.urls(for: .documentDirectory, in: .userDomainMask) | |
.last! | |
} | |
} | |
extension String { | |
var fileName: String { | |
return "your_app_unique_prefix_" | |
+ self | |
+ ".json" | |
} | |
var fileURL: URL { | |
return FileManager | |
.documentsDirectory | |
.appendingPathComponent(fileName) | |
} | |
} | |
extension URL { | |
var fileContent: Data? { | |
return FileManager | |
.default | |
.contents(atPath: path) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment