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: Automatically released when the variable is automatically released from the pool
Auto-Release Pool There's a lot of invisible 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.
This article is from the "Get" blog, so be sure to keep this source http://3517465.blog.51cto.com/3507465/1692010
Objective-c Memory Management 2 Lan Yi Education