ios - Get back variable value from another swift file -


first of all, sorry title not precise.

so, have file data.swift informations

import foundation  class data {     class entry {         let filename : string         let heading : string         let referenceville: string         init(fname : string, heading : string, referenceville : string) {             self.heading = heading             self.filename = fname             self.referenceville = referenceville         }     }      var places = [         entry(fname: "bordeaux.jpg", heading: "heading 1", referenceville : "bordeaux"),         entry(fname: "lyon.jpg", heading: "heading 2", referenceville : "lyon")      ]        var bordeaux = [         entry(fname: "lemarais.jpg", heading: "le marais", referenceville : "lemarais"),         entry(fname: "montmartre.jpg", heading: "montmartre", referenceville : "montmartre"),         entry(fname: "perelachaise.jpg", heading: "pere lachaise", referenceville : "perelachaise"),      ]  } 

in viewcontroller, m trying value above :

var passedvalue:string!  // passedvalue coming segue previous vc // passedvalue "places", "bordeaux", ...      let entry = data.passedvalue[indexpath.row] 

but it's not working message error told me "data doesn't have member named "passedvalue"

how set variable ?

like this:

 let entry = data().places[indexpath.row] 

to access variables in class, need instantiate first ()


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -