Created
January 20, 2017 03:40
-
-
Save castillejoale/f9d1439696e21d174eb6cf77273bc4fd to your computer and use it in GitHub Desktop.
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
import UIKit | |
import AVFoundation | |
//Dictionary string-> Dictionary | |
let dictionaryString = "{\ncode=0;\nphotoLink=\"\";\nplayerLastName=\"\";\nplayerName=\"\";\n}" | |
var arrayOfElements = dictionaryString.characters.split{$0 == "\n"}.map(String.init) | |
arrayOfElements.removeLast() | |
arrayOfElements.removeFirst() | |
var dict = NSDictionary() | |
var dataDict = [String: String]() | |
for element in arrayOfElements { | |
var newString = element.stringByReplacingOccurrencesOfString("\n", withString: "") | |
var sentenceLines:[String] = [] | |
newString.enumerateLines { sentenceLines.append($0.line) } | |
print(sentenceLines) | |
newString = newString.stringByReplacingOccurrencesOfString(";", withString: "") | |
var valueKey = newString.characters.split{$0 == "="}.map(String.init) | |
dataDict[valueKey[0]] = valueKey[1].stringByReplacingOccurrencesOfString("\\", withString: "") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment