Swift - Pass variables between classes

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

  1. etimm macrumors newbie

    Joined:
    Aug 28, 2014
    #1
    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

    Code:
    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

    waterskier2007

    Joined:
    Jun 19, 2007
    Location:
    White Lake, MI
    #2
    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