saad
saad

Reputation: 1245

Passing Data To Delegate

I have a bunch of outlets in a controller object that another controller needs to be passed. If it was only 2 or 3 values, I'd just pass them as parameters to the delegate method (not directly the outlets, but by copying the value to variables)

However, there are quite a few. What is the best way to handle this? I see three approaches:

What is the best way to approach this?

Upvotes: 0

Views: 412

Answers (1)

Nick Weaver
Nick Weaver

Reputation: 47241

You are always allowed to do what you allow yourself. However some approaches may prevent Apple from accepting your App for the Appstore. This is not the case here ;)

If there are many values to pass I'd go for

  • An array if the passed objects contained are of the same type/kind
  • Use a data class if the values are heterogeneous in nature. Like in Refactoring by M.Fowler -> Introduce Parameter Object (page 295).

The dirty way would be, as you suggested, to open the Outlets to other instances than the view controller itself. Prevent that nosy behaviour of other classes.

Upvotes: 1

Related Questions