Model classes - what do they really mean?

I really can't get Model objects hanging in MVC. I wonder why we can’t just work with arrays and dictionaries and arrays of dictionaries?

I understand that they represent the “data” that my other classes are manipulating and working on. But how should they be built? Suppose I have a plist that I want to read and display in a table. I could just load it directly into an array property in my method viewDidLoadand then use it, right? Why would I want to use the Model class, and how would I build it?

In addition, any links to resources / blogs that explain this point would be greatly appreciated!

+3
source share
1 answer

You can absolutely work with dictionaries and arrays - there is nothing wrong with using these components (or the entire) of your data model. Master Data NSManagedObject is very similar to a dictionary. But sometimes you want your model objects to do more than just store data - you might also want them to know something about how different bits of data relate to each other, work with data, etc.

, Person . , ? , firstName, lastName, middleName, , , email, dateOfBirth... , , , . , , .

, , . Person, , fullName, age, initials, monogram vCard. , , . :

- (NSString*)fullName
{
    return [NSString stringWithFormat:@"%@ %@ %@", self.firstName, self.middleName, self.lastName];
}

. , . , , , , , , , , , , -, , .. - , , . , , . . , , , -. . .

+6

All Articles