Created
December 23, 2014 14:54
-
-
Save soffes/a0433d67d2f7b6fcb85b to your computer and use it in GitHub Desktop.
Swift Extensions
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
| // | |
| // NSRange.swift | |
| // MarkdownKit | |
| // | |
| // Created by Sam Soffes on 12/23/14. | |
| // Copyright (c) 2014 Nothing Magical Inc. All rights reserved. | |
| // | |
| import Foundation | |
| public extension NSRange { | |
| public var max: Int { | |
| return NSMaxRange(self) | |
| } | |
| } |
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
| // | |
| // String.swift | |
| // MarkdownKit | |
| // | |
| // Created by Sam Soffes on 12/23/14. | |
| // Copyright (c) 2014 Nothing Magical Inc. All rights reserved. | |
| // | |
| import Foundation | |
| public extension String { | |
| public var bounds: NSRange { | |
| return NSRange(location: 0, length: countElements(self)) | |
| } | |
| public func substringWithRange(aRange: NSRange) -> String { | |
| let start = advance(startIndex, aRange.location) | |
| let end = advance(start, aRange.length) | |
| return substringWithRange(Range<Index>(start: start, end: end)) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment