Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

convert dictionary to array swift

let dic = ["1":"a", "2":"b", "3":"c"]

let arrayOfKeys = Array(dic.keys.map{ $0 })
print(arrayOfKeys) // [1, 2, 3]
let arrayOfValues = Array(dic.values.map{ $0 })
print(arrayOfValues) // [a, b, c]
Comment

swift map array to dictionary

let myDictionary = myArray.reduce([Int: String]()) { (dict, person) -> [Int: String] in
    var dict = dict
    dict[person.position] = person.name
    return dict
}

//[2: "b", 3: "c", 1: "a"]
Comment

PREVIOUS NEXT
Code Example
Swift :: loop backwards swift 
Swift :: swift get "system" asset image 
Swift :: how to set the center in view in swift 
Swift :: uitableview scroll to bottom swift 
Swift :: swiftui actionsheet 
Swift :: change placeholder color swift 
Swift :: swift 5 get app version 
Swift :: swft ui image 
Swift :: uitextview set placeholder text swift 5 
Swift :: sf symbols 
Swift :: swift add two arrays 
Swift :: ForEach tabs swiftui 
Swift :: ios UIButton change image 
Swift :: swift stack view scrollable 
Swift :: uitextfield get focus swift 5 
Swift :: while loop in swift 
Swift :: swift initialize array with size 
Swift :: how to send a file from file manager in mail swift 
Swift :: swift combine 2 sets 
Swift :: Swift Change Value of Dictionary 
Swift :: Incompatible Swift version - framework was built with 5.5 (swiftlang-1300.0.31.1 clang-1300.0.29.1) and the local version is 5.4.2 (swiftlang-1205.0.28.2 clang-1205.0.19.57) 
Swift :: SwiftUI cant tap in spacer of HStack 
Swift :: on edit input field provide default value if textfield get empty swift 
Swift :: chevrondownf6a06a60-2122-49d0-86a0-03ba8c532aec 
Swift :: Swift Labeled Statement with break 
Swift :: selector cannot call in notification observer swift 
Swift :: Example: Nested Tuple 
Swift :: Compare AnyObjects en Swift 
Ruby :: how to get tables list in rails 
Ruby :: brew update ruby 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =