Created
March 5, 2020 15:12
-
-
Save daniloc/1664f913d0b966793da15de548626b33 to your computer and use it in GitHub Desktop.
Revisions
-
daniloc created this gist
Mar 5, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ struct MarkdownFile: ExpressibleByStringLiteral { let bundleName: String let rawMarkdown: String? init(stringLiteral: String) { bundleName = stringLiteral var loadedMarkdown: String? = nil if let filepath = Bundle.main.path(forResource: bundleName, ofType: nil) { do { let loadedString = try String(contentsOfFile: filepath) loadedMarkdown = loadedString } catch { print("Could not load string: \(error)") } } else { print("Could not find file: \(bundleName)") } rawMarkdown = loadedMarkdown } }