比如有個 book *_book
1.set方法的實現
- (void) setbook : (book *)book
if (book !=_book)
[_book release];
_book = [book retain ];
2.dealloc 方法的實現
- (void )dealloc
[_book release];
[super dealloc];
}1.方法的基本操作
1)retain:計數器+1,會返回物件本身
2)release:計數器-1,沒有返回值
3)retaincount :獲取當前的計數器
4)dealloc
*當乙個物件要被**的時候,就會被呼叫
*一定要呼叫[super dealloc ],這句呼叫要放在最後面
黑馬程式設計師 map集合的基本方法
asp.net unity開發 net培訓 期待與您交流!map集合 該集合儲存鍵值,一對一對往裡存,而且保證鍵的唯一性 基本方法 class mapdemo 新增元素,如果出現相同的鍵,那麼厚新增值會覆蓋原有鍵對應值,並put方法會返回被覆蓋的值。map集合的兩種取出方式 1 keyset 將ma...
黑馬程式設計師 方法簡介
asp.net android io開發s net培訓 期待與您交流!方法 方法的宣告 public static void 方法名 引數列表 public 訪問修飾符。static 表示靜態的。void 返回值的型別,如果沒有返回值,就寫 void 如果有返回值,就寫對應的型別 方法名 必須符合p...
黑馬程式設計師 description方法
今天覆習時,發現想對物件輸出一些資訊時,nslog不能滿足要求,特對此總結一下重寫description方法 重寫 nslog 的輸出格式 nslog p 1 會呼叫物件p的description方法 2 description方法會把返回值 nsstring 顯示到螢幕上 3 descriptio...