David
David

Reputation: 7525

IOS Swift: Pass data to another controller

I am trying to pass data from one view controller to another.... I have a collection view in the first view controller which is populated dynamically with an array and want it so that when an item is clicked... it opens up the second view controller (which I've done) but sends along data (in this case an array)

Ive looked into core data, but after trying to implement it thought it might be a bit "overkill" for such a basic function? (or am i wrong?)

Anyone have any ideas?

Thanks, Dave

Upvotes: 0

Views: 439

Answers (1)

Wyetro
Wyetro

Reputation: 8588

Have you tried using prepareForSegue:

override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) {
        // pass data to next view
}

Or NSUserDefaults:

NSUserDefaults.standardUserDefaults().setObject(VALUE, forKey:YOUR_KEY)
NSUserDefaults.standardUserDefaults().synchronize()

Upvotes: 1

Related Questions