A.concepts explain:
Object:which is created from struct or class template
Instance:which is just used to declare a reference of class or struct it's created from, and it's the same meaning as O Bject
B.purpose:
The purpose to use class or struct as the template of objects are to prevent tightly coupled components, which means to mak E the different the same project to a lower relationship with each other,further Component in the project we don ' t has to change the other component very much and maybe even rewrite the other components .
Much more clear, when we access one object from another one, we only can see the name of the properties and Metho DS (include return value), we have no idea about the implementation. In Swift we had access control, using public, private or internal as the mark. Internal:the default value without specifying the mark. and can be accessed in the same project.
Private:specify the private mark before the property and Methods.only can is accessed from the same file
Public:specify the public mark before the property and methods. Usually used when develop framework and can is accessed outside of the project.
Using Access control we can only expose the API we want the other objects to use, and hide the properties or methods we do NT want to, which can leads to loosely coupling.
For example, we can use computed properties to being the API for other objects, and we can use the Set{}or get{}to interact W ith private value and add more spedified logic.
Sorry guys i ' m using a Chinese blog website, so I had no idea if there was a blog I can use in 中文版, please leave any C Omments below and the related Chinese word is "review", thank you so much for your reading, and if you had any suggestions ple ASE Leave it below.
Ios-design patterns-object Template (Swift)