guard all the things! 👮
This commit is contained in:
@@ -9,11 +9,11 @@ public class Template {
|
||||
/// Create a template with the given name inside the given bundle
|
||||
public convenience init(named:String, inBundle bundle:NSBundle? = nil) throws {
|
||||
let useBundle = bundle ?? NSBundle.mainBundle()
|
||||
if let url = useBundle.URLForResource(named, withExtension: nil) {
|
||||
try self.init(URL:url)
|
||||
} else {
|
||||
guard let url = useBundle.URLForResource(named, withExtension: nil) else {
|
||||
throw NSError(domain: NSCocoaErrorDomain, code: NSFileNoSuchFileError, userInfo: nil)
|
||||
}
|
||||
|
||||
try self.init(URL:url)
|
||||
}
|
||||
|
||||
/// Create a template with a file found at the given URL
|
||||
|
||||
Reference in New Issue
Block a user