Created
August 16, 2016 06:12
-
-
Save wanbok/d8b8508e7888edaacfb39f7ba23000c3 to your computer and use it in GitHub Desktop.
join for NSAttributedString
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
extension CollectionType where Self.Generator.Element : NSAttributedString { | |
func join(separator: String? = nil) -> NSAttributedString { | |
let mutableAttributedString = NSMutableAttributedString() | |
self.forEach { | |
if let separator = separator where self.first != $0 { | |
mutableAttributedString.appendAttributedString(NSAttributedString(string: separator)) | |
} | |
mutableAttributedString.appendAttributedString($0) | |
} | |
return mutableAttributedString | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment