objective-c - ios model 有一個屬性也是model型,初始化時,進入死循環,怎麼破?
仅有的幸福
仅有的幸福 2017-04-26 09:01:54
0
1
599
  • (instancetype)initFromDictionary:(NSDictionary *)dictionary
    {ShowLog
    self = [super init];
    if (self) {

       _cid        =       StringValue(dictionary, KID);
       _user       =       [[User alloc] initFromDictionary:DictionaryValue(dictionary, Kuser)];
       _images     =       ArrayValue(dictionary, Kimages);
       _content    =       StringValue(dictionary, Kcontent);
       
       //_beCommented=       [[Comment alloc] initFromDictionary:DictionaryValue(dictionary, KbeCommented)];
       _createTime =       DateValue(dictionary, KcreateTime);
       _ownerId    =       StringValue(dictionary, KownerId);

    }
    return self;
    }

註解那個行使程序進入了死循環,這個要怎麼改?

仅有的幸福
仅有的幸福

全部回覆(1)
phpcn_u1582

屬性用getter方法初始化載入也很方便,一個方法裡面又要呼叫自己,需要有一個結束條件。

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!