Difference between release and dealloc in objective-c

后端 未结 3 637
野趣味
野趣味 2020-12-13 12:51

When deallocing a refrence I\'ve seen release and dealloc being used for example

-(void)dealloc
{
  [foo release];
  [nar dealloc];         


        
3条回答
  •  执笔经年
    2020-12-13 13:37

    The dealloc statement in your example is called when the object's retain count becomes zero (through an object sending it a release message).

    As it is no longer needed, it cleans itself up by sending a release message to the objects that it is holding on to.

提交回复
热议问题