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 :: swift tuple 
Swift :: string.format swift 
Swift :: porsche 
Swift :: get day difference between two dates swift 
Swift :: struct vs enum swift 
Swift :: closure swift 
Swift :: how to change the color of back button navbar xcodee 
Swift :: power swift 
Swift :: add to beginning of array swift 
Swift :: rxswift combine two observables 
Swift :: swift 5 get app version 
Swift :: ios make http request 
Swift :: navigationBarTitle text size swiftui 
Swift :: swift constructor 
Swift :: swift array map to another array 
Swift :: response.result.value alamofire 5 
Swift :: xcode execute code after when navigating back to screen 
Swift :: swift guard statement 
Swift :: swft view 
Swift :: how to send a file from file manager in mail swift 
Swift :: repeat...while Loop Swift 
Swift :: set time programmatically swift 
Swift :: uitableview total number of rows 
Swift :: Button on right side/view of UITextField 
Swift :: 95 dollars in rupees 
Swift :: uilabel without constraint 
Swift :: view rounded corners swift 
Swift :: swift split an array into chunks 
Swift :: where to save audio asset swift 
Swift :: swift allow gesture recognizer over others 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =