Generics: restriction type
Why quit generics: catering to Swift
The role of generics: 1. Type of restriction; 2. Improve code specifications, reduce communication costs, see what's in the collection at a glance
Generic definition Usage: type < restriction type >
Generic declaration: When declaring a class, after the class < generic name >
Generic usage errors are reported only as warnings in OC
Benefits of Generics: 1. Remove from the array, you can use dot syntax
2. Add an element to the array with hints
Usage scenarios for generics in development: 1. To restrict collection types
ID is not used for dot syntax
Why can a collection use generics? To use generics, you must first declare the generic type. = "How to declare a generic type
Custom generics? When do I use generics? When declaring a class, it is not certain that some property or method type is determined when using this class, and it can take a generic
such as: Custom person class, some programming language (Ios,java), in the Declaration of people, not sure what the man will be, in the use of someone only to know what language. If generics are not defined, the default is ID
For parent-child type conversion generics: _coveriant: Covariant subclass to Parent class
_contravariant: Inverter-Parent Rotor class
Generics Note: In an array, the generic variable group adds a method, the generics do not take effect, and if you add elements using an immutable group, the generics have no effect.
IOS9 new characteristics of the generic type