MVC that was wrongly understood and used

In the current work in the use of MVVM (learning), today suddenly realized that the MVC understand the wrong.

Current understanding

Application is to deal with a series of data, and then presented to the user.
model is used to handle these data, such as requests, mapping, filtering, sorting……
view is used to display data, interact with the user.
controller is used to coordinate V with M.

For example, for example, here are some of the code. Specific please see here

Model.h

#import < Foundation/Foundation.h> @interface Model: NSObject @property (nonatomic, strong) NSArray *personArray; (void) fetchPersonArray; @end

Model.m

#import "Model.h" #import "Person.h" @implementation Model (void fetchPersonArray) {/ / / / / / or request network access to the database Person *person1 [Person personWithName:@ = "AAAAA" age:1]; Person *person2 = [Person personWithName:@ "bbbbb" age:2]; Person *person3 = [Person personWithName:@ "ccccc" age:3]; Person *person4 = [Person personWithName:@ ddddd age:4]; self.personArray = @[person1, person2, person3, person4]; @end}

Person.h

#import < Foundation/Foundation.h> @interface; Person: NSObject @property (nonatomic, copy) NSString *name; @property (nonatomic, assign) NSInteger age; (instancetype) + personWithName: (NSString *) name age: (NSInteger) age; @end

ViewController.m

#import "ViewController.h" #import "Model.h" #import "Person.h" #import "View.h" @interface (ViewController) @property (nonatomic, strong) Model *model @property (nonatomic, strong); View *customView; @end implementation @ ViewController - (void) viewDidLoad viewDidLoad] self.model {[super = [[Model; alloc] init]; [self.model addObserver:self forKeyPath:@ "personArray" options:NSKeyValueObservingOptionNew context:nil]; self.customView [[View alloc] = init]; self.customView.frame = self.view.bounds; [self.view addSubview:self.customView]; [self.model fetchPersonArray];} - (void) observeValueForKeyPath: (NSString *) keyPath ofObject: (ID) object change: (NSDictionary< NSKeyValueChangeKey, id> contex * Change) T: (void * context) {if ([keyPath isEqualToString:@ "personArray"]) {[self}} - (updateUI]; void) {updateUI self.customView.personName1.text = [self.model.personArray[0] name] = [self.model.personArray [1]; self.customView.personName2.text name]; self.customView.personName3.text [self.model.personArray[2] = name]; self.customView.personName4.text = [self.model.personArray[3] name] @end;}

Of course, the above understanding is not correct, but it is certain that I was wrong.
feel very ashamed, so long, remember!!!

Previous understanding (error)

Model is a data model, such as the role of Person in the above
view is used to display data, interact with the user.
controller is used to process logic and coordinate V with M.

The example above will achieve the following in the wrong way, please see the specific code here

Model.h

#import < Foundation/Foundation.h> @interface; Model: NSObject @property (nonatomic, copy) NSString *name; @property (nonatomic, assign) NSInteger age; (instancetype) + personWithName: (NSString *) name age: (NSInteger) age; @end

ViewController.m

#import "ViewController.h" #import "Model.h" #import "View.h" @interface (ViewController) @property (nonatomic, strong) NSArray *personArray @property (nonatomic, strong); View *customView; @end @implementation ViewController (void viewDidLoad) {[super viewDidLoad]; self.customView [[View alloc] = init]; self.customView.frame = self.view.bounds; [self.view addSubview:self.customView]; __weak ViewController *weakSelf = self [self; fetchPersonArray:^{}]; [weakSelf updateUI];} - (void) fetchPersonArray: (void (^) (void)) {Model *person1 = completion [Model personWithName:@ "AAAAA" age:1]; Model *person2 = [Model personWithName:@ "bbbbb" age:2]; Model *person3 = [Model personWithName:@ CCC CC age:3]; Model *person4 = [Model personWithName:@ "ddddd" age:4]; self.personArray = @[person1, person2, person3, person4]; if (completion) {}} - (completion); updateUI (void) {self.customView.personName1.text = self.personArray[0] [name] = [self.personArray[1]; self.customView.personName2.text = name]; self.customView.personName3.text [self.personArray[2] name]; self.customView.personName4.text [self.personArray[3] @end = name];}