Created
March 7, 2017 07:10
-
-
Save usagimaru/ac2a73fc389944c3b6c988f8c409c3d1 to your computer and use it in GitHub Desktop.
IndexPathExtension.swift
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
import Foundation | |
extension IndexPath { | |
static func fromString(_ string: String) -> IndexPath? { | |
let strs = string.components(separatedBy: ",") | |
var indexPath = IndexPath.init() | |
for str in strs { | |
if let i = Int(str) { | |
indexPath.append(i) | |
} | |
} | |
return indexPath | |
} | |
func stringValue() -> String { | |
var str = "" | |
var i = startIndex | |
while i < endIndex { | |
if str.characters.count != 0 { | |
str += "," | |
} | |
str += "\(i)" | |
i = index(after: i) | |
} | |
return str | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment