Objective-C Callbacks and Notifications

I am new to Objective-C, not a full-time programmer. I'm starting to understand the Model-View-Controller design pattern to differentiate the user interface from the model. Thus, the user takes the action, and the view controller sends a message to the delegate (model). But I'm not sure what the best way to send actions from the delegate back to the view controller.

For example, a user clicks a button, a VC message is a delegate. I understand this part. Then the delegate takes action, and after that the delegate wants to update the VC (for example, update the label).

So I skipped (or forgot) how to do this while maintaining the separation between the user interface and the model. I guess I can use the notification center. Or I think that I can just pass the callback to the delegate to the view manager. Or maybe there is another choice that I do not know about. Can someone give me a recommendation, please?

+3
source share
3 answers

, MVC. , - . , ( /), ( UIViewController iOS). , . MVC .

+4

, , (, NotificationCenter), UI-Stuff, IBAction -Methods IBOutlet -Properties , UI-Elements Interface Builder.

: iPhone SDK Interface Builder , , .

0

.

- , (DB, plist, , ..).
- , , .
, , .

The view controller must respond to user actions.
If the button displays some data from your model on a label, then viewing the controller should do all the work (take a user action, take the necessary data from the model and display it in the view ...).

-1
source

Source: https://habr.com/ru/post/1755455/


All Articles