Swift - Pass variables between classes

Discussion in 'iOS Programming' started by etimm, Aug 28, 2014.

  1. etimm macrumors newbie

    Aug 28, 2014
    I would like to know what the best way is to pass variables between classes.
    I have one class named "storage" where I want to store variables

    class storage {
    var text: String
    var location: String
    I have two view controllers, one where the information comes from that I would like to store in the storage class and one where I would like to retrieve the data I've stored in class storage.

    (I can't use segues because I'm not using use the storyboard)
  2. waterskier2007 macrumors 68000


    Jun 19, 2007
    Novi, MI
    Can't you just assign the variable to a property on the new ViewController when you instantiate it. You must be presenting the ViewController somehow...

Share This Page