Created
August 24, 2015 03:19
-
-
Save kitasuke/0dc04c4d9e97cca4157d to your computer and use it in GitHub Desktop.
String extension in Swift for Xcode beta5
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 String { | |
var lastPathComponent: String { | |
get { | |
return (self as NSString).lastPathComponent | |
} | |
} | |
var pathExtension: String { | |
get { | |
return (self as NSString).pathExtension | |
} | |
} | |
var stringByDeletingLastPathComponent: String { | |
get { | |
return (self as NSString).stringByDeletingLastPathComponent | |
} | |
} | |
var stringByDeletingPathExtension: String { | |
get { | |
return (self as NSString).stringByDeletingPathExtension | |
} | |
} | |
var pathComponents: [String] { | |
get { | |
return (self as NSString).pathComponents | |
} | |
} | |
func stringByAppendingPathComponent(path: String) -> String { | |
let nsSt = self as NSString | |
return nsSt.stringByAppendingPathComponent(path) | |
} | |
func stringByAppendingPathExtension(ext: String) -> String? { | |
let nsSt = self as NSString | |
return nsSt.stringByAppendingPathExtension(ext) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment