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
var dict:[[String:String]] = [["name":"a"],["name":"b"],["name":"a"]] | |
let filteredDict = filter(dict) | |
func filter(_ arrayOfDicts:[[String:String]]) -> [[String:String]] { | |
var filteredDict = [[String:String]]() | |
var filteredName = [String]() | |
for d in arrayOfDicts { | |
if let name = d["name"], !filteredName.contains(name) { | |
filteredDict.append(d) |
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
let arrayOfDict:[[String:String]] = [["name":"a"],["name":"b"],["name":"a"]] | |
var filteredDict = [[String:String]]() | |
var filteredName = [String]() | |
arrayOfDict.map{dict in | |
if !(filteredName.contains(dict["name"]!)) { | |
filteredDict.append(dict) | |
filteredName.append(dict["name"]!) | |
} | |
} |
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
struct RgbToHex: OptionSet { | |
let rawValue: Int | |
func convertRGBToHex(r: RawValue, g: RawValue, b: RawValue) -> String { | |
return String(format: "%X", (r << 16 | g << 8 | b)) | |
} | |
} | |
let hex = RgbToHex().convertRGBToHex(r: 240, g: 200, b: 100) | |
print(hex) |
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 Foundation | |
import UIKit | |
struct StoryboardIdentifiers { | |
static let ViewController1 = "ViewController1" | |
static let ViewController2 = "ViewController2" | |
static let ViewController3 = "ViewController3" | |
static let ViewController4 = "ViewController4" | |
static let ViewController5 = "ViewController5" | |
static let ViewController6 = "ViewController6" |