Today is study day, I have learned from the beginning of school to the knowledge of all over again, will be very skilled to skip, have a look at the unfamiliar, do not understand the emphasis on learning, the whole process accompanied by making notes, the knowledge summed up into their own understanding of the text to be kept separate, then do not like today spend a lot of time to review Just take a look at your own notes.
Memory management is important and requires a good understanding of digestion.
Three methods commonly used in manual memory management (MRC)
Retain: Causes memory count +1
Release: Causes memory Count-1
Copy: Copies a new object and the data of the previous object may be consistent but not the same object memory count is 1
Autorelease: Auto-release when the variable is out (auto-release pool) automatically releases a lot of invisible auto-release pools in the project
Attribute Description Keywords:
Retain/strong:
If retain would do two things,
-(void) Setnames: (Nsmutablearray *) names{
The first thing to release-1 the original
[_names release];
The second thing to pass in the new retain +1
_names = [names retain];
//
//
//}
The attribute life time retain plus 1 executes the Dealloc method when the current object is destroyed release-1
Assign/weak:
If this is the assign or weak set method, only one thing is done.
-(void) Setage: (int) age{
//
_age = age;
//
//}
Copy
If you're doing one thing in the copy set method
-(void) Setnames: (Nsmutablearray *) names{
//
_names = [names Copy];
//}
ReadOnly: If ReadOnly is used, the property will only generate a Get method without a set method
Nonatomic: Non-atomic Operation unsafe efficiency high non-multithreading are used Nonatomic
Atomic: Atomic operation thread security inefficient only when multiple threads access data can you use this keyword
All basic data types are assign or weak but because they are the default, you don't have to write anything.
All object types (except NSString) are used with strong or retain
NSString needs to be modified with copy to avoid a chain reaction that alters a string that causes a series of related strings to change.
Lan Yi iOS Training Log 6 Study day notes and review memory management