1

Is there any way that could send the value in Class of ViewController to Class of View? Because I want to make a drawing board and I made a modal scene to set values about color, width . I know how to send the value in modal scene to my ViewController , but now I need use those value in Class of View , or not Class of ViewController.

AstroCB
  • 12,337
  • 20
  • 57
  • 73
qk93cn
  • 11
  • 1
  • I have my answer here: http://stackoverflow.com/questions/25616250/refreshing-parent-viewcontroller-after-dismissing-modalviewcontroller/25617263#25617263 – Allan Macatingrao Sep 06 '14 at 04:20

2 Answers2

0

Sounds like you need to devise a protocol to open a delegation channel between the two classes. Then when the modal VC wants to send data to its delegate (its presenter, in this case), it can of its own volition.

Gutblender
  • 1,340
  • 1
  • 12
  • 25
0

The View Controller can have a reference to the View, therefore the View Controller can simply pass the values to View by calling a View's method or updating View's properties. This is a common pattern: View defines a Protocol and data/requests from View to ViewController go through this Protocol (the ViewController acts as delegate of View); and ViewController owns the View.

For inspiration on how to implement a farily decoupled design applying this pattern, you can have a look at documentation on UICollectionView and UICollectionViewController.

Other options, depending on what design you need, are Key-Value Observing or Notifications.

George
  • 1,235
  • 10
  • 23