user42541
user42541

Reputation: 67

Running code after i perform a segue?

Is there a way I can run code after performSegueWithIdentifier? So a button performs a segue to view controller 2 and in view controller 2 I want it to execute "refresh" code (populating its table view via parse.com).

Right now I have the "refresh" code in view controller 2's viewDidAppear, but changing it to perform the "refresh" code after doing the segue would reduce API requests.

Upvotes: 0

Views: 524

Answers (1)

Aaron Brager
Aaron Brager

Reputation: 66234

You typically use prepareForSegue(_:sender:) to execute code before the segue is executed, or viewDidLoad() for code that you want to execute when the segue is finished.

For finer control, you could subclass UIStoryboardSegue and create a custom segue, but it doesn't sound like you need that for this issue.

Upvotes: 3

Related Questions