---------------------------
asp.net+unity開發
、.net培訓
、期待與您交流!---------------------------
關於迴圈引用的解決方法:
兩端迴圈引用解決方案
1>一端用retain
2>一端用assign
首先定義兩個類:card、person,其中card中又person的屬性,person中又card得屬性。
(1)card的宣告:
@class person;//告訴編譯器,person是乙個類
@inte***ce card : nsobject
//一端用retain
@property (nonatomic, retain) person *person;
@end
card的實現:
#import "card.h"
@implementation card
@end
(2)person的宣告:
//僅僅告訴編譯器,card是乙個類
@class card;
@inte***ce person : nsobject
//另一端用assign
@property (nonatomic, assign) card *card;
@end
person的實現:
#import "person.h"
@implementation person
@end
使用的測試**:
#import "person.h"
#import "card.h"
/* 1.@class的作用:僅僅告訴編譯器,card是乙個類
2.開發中引用乙個類的規範:
1>在.**件中用@class來宣告類
2>在.m檔案中用#import來包含類的所有東西
3.兩端迴圈引用解決方案
1>一端用retain
2>一端用assign
*/int main(int argc, const char * ar**)
-----------------------------asp.net+unity開發、.net培訓、期待與您交流!---------------------------
詳細請檢視:www.itheima.com
黑馬程式設計師 Object C 類別
類別是一種為現有的類新增新方法的方法。宣告類別 類別的宣告格式和類的宣告格式相似 inte ce nsstring numberconvenice 類別的名稱是numberconvenience,該類別將向nsstring類中新增方法 nsstring lengthasnumber end 宣告具有...
黑馬程式設計師 Object C 物件的特性
特性 property 是object c 中組合了新的預編譯指令和新的屬性的訪問器語法。新的特性功能顯著減少了必須編寫的冗長 的數量。老 inte ce allweatherradial tirl void setrainhandling float rainhandling float rain...
黑馬程式設計師 迴圈結構
asp.net unity開發 net培訓 期待與您交流!迴圈結構 1 while while迴圈的基本語法 while 表示式1 語句2 執行過程 1 對表示式1進行求值 2 如果表示式1的值為false,則跳轉到第4步,如果表示式1的值為true,則跳轉到第3步 3 執行迴圈體,然後跳轉到第1步...