Delegate vs Segue

I’ve finished through the first 2 apprentice iOS tutorials, and I must admit they are smashing.

I have run into a bit of a question that I’m looking to get some help with regarding which is preferred to use, a delegate vs passing information to another ViewController.

Within the tutorial it gets done both ways, and I understand the idea behind the delegates (do the thing and I don’t care how), I’m just curious if there is a scenario if one is preferred over the other.

Best,

Well delegates are used when you may want to expose the protocol functionality to other view controllers later on.

Its a bit more elegant and clean some might say.

So unless you’re wanting extra functionality on the data, passing the information via a prepareforsegue function might be a leaner solution?

Yeah, definitely. You are simply setting a ‘variable’ (property) on another object, ie the destinationViewController.

1 Like