Object-c: an object-oriented understanding
After learning C language, I know that the difference between the two languages is a little big. C language is a process-oriented language, and O-C is an object-oriented language, for example (of course it is old), just like a sketch of Zhao Benshan and Song Dandan during the Spring Festival, it is said to put the elephant in the refrigerator in a few steps. I guess you already know the answer, there are three steps.
Step 1: open the refrigerator door
Step 2: Put the elephant in
Step 3: Close the refrigerator door
If we use C language for implementation, we need to write three functions to implement three functions. First, we need to create a function to open the refrigerator door. Second, we need to create a function, the third step is to create a function to close the refrigerator door.
However, the object-oriented language actually operates on objects. Unlike the C language, we only need to know who the object is. Who are we going to operate on in this question? The answer is of course the refrigerator. Now we have changed from the original executor to the conductor. We only need to tell the refrigerator the operation we want to perform, as for how to implement it, we don't care about it (or you want to care that Apple's source code is closed, and you don't see it either. You just need to know which functions are called to implement which functions)
Here, we only need to execute the function functions of the three refrigerators.
1. First create a refrigerator object
2. open the refrigerator (just tell him to open it)
3. Refrigerator. Put the elephant in (just tell him we want to store it)
4. Close the refrigerator (just tell him we want to use this function to close the door)
Here, we will not care about how to open it, how to put the elephant in, and how to close the door.