Created
August 31, 2015 20:27
-
-
Save x43x61x69/6174c7c20db26de52293 to your computer and use it in GitHub Desktop.
Xcode 7 beta - String Extension for NSString Methods
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
// From: https://forums.developer.apple.com/thread/13580 | |
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