<a href= "http://www.goodprogrammer.org/" target= "blank" >ios training </A>------My obj-c language notes, looking forward to communicating with you!
The Obj-c constructor starts with Initwithxxxx (initializes the related work)
1 -(id ) init { 2 self = [super Init]; 3 use [ Super] The object of the parent class 4 // self represents the object of this class 5 if 6 7 } 8 return self; 9 }
1 -(ID) Initwithname: (NSString *) newName;
2 -(ID) Initwithname: (NSString *) newName withage: (int) newage;
destructor Dealloc (function called before the object is destroyed)
1 -(void ) dealloc { 2 // when the object disappears completely. 3 Object counters are called when objects are destroyed = 0 4 // This dealloc function does not think that the call is [XX Dealloc] 5 // 6 Release destroy object Release counter-1 to 0 automatically skips the [dealloc] function 7 [Super Dealloc]; 8 }
1 // Call only once 2 // class method, which is called when the class is first instantiated 3 + (void) initialize;
"Good Programmer's note sharing" Obj-c's structural destructor