2009年2月9日 星期一

create object ,new, alloc, init, dealloc

new:
ex:
id c = [Circle new];

when creating object with new, two steps are performed :
(1) allocate memory for object
(2) object's init method is called
ex: 
- (id) init
{
self = [super init];
return self;
}

alloc:
initialize all memory to 0
Hence, all instance variable have zero value
pointer to objects are nil
integer variable is 0

dealloc:
- (void) dealloc
 

沒有留言:

張貼留言