Created
July 13, 2017 18:17
-
-
Save khanlou/288900646121497bf2c965b91bb4890f to your computer and use it in GitHub Desktop.
Mutable pathExtension on URLComponents
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 characters
| // Swift 3 | |
| extension URLComponents { | |
| var pathExtension: String { | |
| get { | |
| return NSString(string: self.path).pathExtension | |
| } | |
| set { | |
| let nsStringPath = NSString(string: self.path) | |
| let nsStringPathWithoutExtension = NSString(string: nsStringPath.deletingPathExtension) | |
| if let nsStringWithNewExtension = nsStringPathWithoutExtension.appendingPathExtension(newValue) { | |
| self.path = nsStringWithNewExtension | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment