1. Dictionary Turn model
========================================
Benefits of 1.1 dictionary to model:
1 > Reduce the coupling of the Code
2 > All Dictionary-to-model sections of code are centralized in one place, reducing the chance of code errors
3 > Direct use of the model's attribute operations in the program to improve coding efficiency
The model should provide a construction method that can pass in the dictionary parameters
-(instancetype) initwithdict: (Nsdictionary *) dict;
+ (instancetype) xxxwithdict: (Nsdictionary *) dict;
1.2instancetype & ID
1 > instancetype on a type representation, as with an ID , can represent any object type
2 > Instancetype can only be used on return value types and cannot be used as an ID on parameter types
3> instancetype One more benefit: The compiler detects the true type of instancetype
1.3 Adding readonly properties to the model
// defines a property, the Getter&setter method is generated, and an underlined member variable is generated
// and if it is the readonly property, only the getter method is generated and no member variable
@property (nonatomic, strong, readonly) UIImage *image;
@interface Lfappinfo ()
{
UIImage *_imageabc;
}
-(UIImage *) image
{
if (!_IMAGEABC) {
_IMAGEABC = [UIImage imagenamed:Self. icon];
}
return _imageabc;
}
Reasonable use of read-only attributes in the model can further reduce the coupling of the code.
1.4 Benefits of using the data model:
* * * caller does not care about any processing details inside the model!
2. XIB
========================================
The Xib file can be used to describe a piece of local UI interface
XIB & Storyboard
Same point:
1 > is used to describe the software interface
2> are edited with the Interface Builder tool
Different points
1 > Xib is lightweight and is used to describe the local UI interface
2 > Storyboard is a heavyweight, a multi-interface for describing the entire software, and can show a jump relationship between multiple interfaces
3. View Packaging Ideas
========================================
1 > If you have more than one child control inside a view , you will typically consider customizing a viewto shield the creation of its inner child controls from the outside world.
2 > the outside world can pass in the corresponding model data to the view, theview gets the model data and sets the corresponding data to the inner child control.