Last active
March 9, 2016 13:47
-
-
Save sgr-ksmt/2b324dec9522e7554145 to your computer and use it in GitHub Desktop.
FilePathConvertible : http://blog.sgr-ksmt.org/2016/03/09/filepath_convertible/
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
public protocol FilePathConvertible { | |
var filePath: String { get } | |
var fileURL: NSURL { get } | |
} | |
extension String: FilePathConvertible { | |
public var filePath: String { | |
return self | |
} | |
public var fileURL: NSURL { | |
return NSURL(fileURLWithPath: self) | |
} | |
} | |
extension NSURL: FilePathConvertible { | |
public var filePath: String { | |
return self.path! | |
} | |
public var fileURL: NSURL { | |
return self | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment