swift - insert array values into an empty dictionary -


i have array = [14, 1087, 28474]. how suppose make [fantasy, action, animation] 14 = fantasy , 1087 = action , on. want show string representation of value ios label. there way can that. should make empty dictionary , if how suppose generate keys values inside arrays

you haven't said have tried, dictionary way go. if make dictionary var, can add later. if don't need change it, define let @leo suggests

    var dict : [int : string] = [         14 : "fantasy",         1087 : "action",         28474 : "animation"     ]      let thisnumber = 1087     let thisstring = dict[thisnumber] 

Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -