lundi 18 avril 2016

Best way to modify UIView Outside UIViewController

I try to create a class MyViewControllerDesign.swift, that handle all design setting, like configuration, modification... and that can be called from everywhere.

enter image description here

What is the best way to modify an UIView, that was created in a MyUIViewController, from an function of MyViewControllerDesign ?

1 - Should I pass context of MyUIViewController to hideMyView function ?

func hideMyView(context: MyUIViewController){
   context.myView.hidden = true
}

2 - Or should I pass the view to hideMyView function ?

func hideMyView(myView: UIView){
   myView.hidden = true
}

... but I have to pass it from startTasks too...

func startTasks(myView: UIView){
   ...
   myViewControllerDesign.hideMyView(myView)
   ...
}

3 - Or should I let hideMyView function on MyUIViewController ?

What is the best way ? Is there a design pattern to handle that case ?

Aucun commentaire:

Enregistrer un commentaire