Some things, although not important, but bits and pieces will be used, just make a statement:
There are 2 keywords in the protocol that control whether the method is implemented (by default, @required) and, in most cases, the communication between programmers @required: This method must be implemented (if not implemented, the compiler warns)@required- (void)test; - (void)test2; @optional: This method is not necessarily implemented
@optional
- (void)test3;
The semantics of @synthesize is that if you do not implement setter methods and Getter methods manually, then the compiler will automatically add these two methods to you.
@dynamic tells the compiler that the setter and getter methods of the properties are implemented by the user themselves and are not generated automatically. (Of course, for ReadOnly properties, only getter is required). If a property is declared as @dynamic var and then you do not provide @setter method and @getter method, it is not a problem to compile, but when the program runs instance.var = someVar , the program crashes due to the lack of setter method, or when run to someVar = var , due to lack of get The TER method can also cause crashes. Compile-time is no problem, the runtime executes the corresponding method, which is called dynamic binding.
The bits and pieces that iOS needs to use