objective c - how to pass data to the parent class in ios? -


i beginner in objective-c. please forgive if question silly.

in root view controller a, added subview b. in b there subview c. c contains subview d. how can call method in a d. know can use delegates passing data parent controller. question need create delegate calls c d , 1 call b c , on? or there method directly calls method in a d?

but question need create delegate calls c d , 1 call b c , on?

the view controller's job manage it's view , of view's subviews. if you've got view needs send view controller message, control needs send message somewhere when user changes value, view controller should aware it's there. in such case, view controller can take care of setting (or other appropriate object) said subview's delegate or target when view hierarchy loaded, this:

- (void)viewdidload {     self.needcontrol.delegate = self; } 

that way, needy control doesn't need know object delegate. it's not assuming object view controller, or parent view, or else. cares has delegate, , delegate implements necessary methods. , that, in turn, helps keep code more flexible , maintainable , maybe reusable.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -