1. In OC, each object has a hold count, and each object has a retention count of 1 at the time of creation, and a retention count of 0 when released.
2. Create (auto-release) objects
+ (CAR *) car
{
Car *mycar = [[Car alloc] init];
return [MyCar autorelease];
}
3. Create a reserved property
@property (retain) Nsarray *colors;
After synthesize (synthesis) is created, the object is automatically persisted, and if the object is re-assigned, the preceding value is automatically freed
4. Other ways to create objects
General rules: By Alloc, new, create, copy of any method to build an object, you have to assume the responsibility to release the object , and the class method is different, the method with these words will not generally return the object automatically released
5. Releasing objects
Release properties: Self.year = nil;
Release variables: [age release];