iOS YYModel使用方法

2021-07-31 02:43:40 字數 1751 閱讀 9981

nsdictionary *testdic = @,@,@

]};

此處我設定 groupusermodel 和 usermodel

@inte***ce

groupusermodel : nsobject

@property (nonatomic, copy) nsstring *groupid;

@property (nonatomic, strong) nsarray *result;

@end

#import "groupusermodel.h"

#import "usermodel.h"

@implementation

groupusermodel

// 包含

+ (nsdictionary *)modelcontainerpropertygenericclass ;

}// 白名單

+ (nsarray *)modelpropertywhitelist

@end

@inte***ce

usermodel : nsobject

@property (nonatomic, copy) nsstring *name;

@property (nonatomic, copy) nsstring ****;

@end

#import "usermodel.h"

@implementation

usermodel

// custom

return @;

}// 白名單

+ (nsarray *)modelpropertywhitelist

@end

解決
self.groupusermodel = [groupusermodel yy_modelwithdictionary:testdic];

self.dataarray = [nsmutablearray arraywitharray:self.groupusermodel.result];

for (usermodel *model in

self.dataarray)

問題二: 有時我們model中 .m 檔案中寫下面幾個方法,老是沒有提示,需要人工複製。。。

+ (nullable

nsdictionary

*)modelcontainerpropertygenericclass;

+ (nullable

nsdictionary

+ (nullable

nsarray

*)modelpropertywhitelist;

+ (nullable

nsarray

*)modelpropertyblacklist;

其實只要讓 model 遵從協議就 ok 啦

問題三:直接用陣列轉 model

@inte***ce

nsdictionary (yymodel)

+ (nullable

nsdictionary *)yy_modeldictionarywithclass:(class)cls json:(id)json;

注意這個方法,直接套就 ok 啦

總的來說,github 中的說明文件足夠可以滿足我們的需求,細心閱讀,我出問題也是沒有詳細了解的原因

pythonpip使用方法 pip使用方法整理

匯出專案已安裝的pip包 pip list 檢視專案中安裝的包 pip freeze requirements.txt 將專案中所用到的第三方庫輸出到requirements.txt中 pip install 版本號 pip install i 本次使用清華源進行安裝 離線安裝第三方庫 一鍵安裝整個...

使用方法 離型劑使用方法

1 使用離型劑前必須確保模具乾淨,無粉塵 蠟垢 樹脂垢 油汙等殘留物質。可以使用專用的模具潔模劑進行清洗,不可用其他液體清洗,以免清洗不乾淨或損壞模具。另外,如果您的模具是新的,在清洗乾淨後,務必要對模具進行初步處理,用離型劑在模具表面噴 刷塗5 6次,之後方可正常投入生產。2 使用離型劑時,首先要...

使用方法 卡丁車輪胎使用方法

輪胎的使用方法很重要 卡丁車輪胎是卡丁車場日常執行中的主要易損件,但是輪胎的使用方法很重要。哪些情況下會縮短輪胎的使用壽命呢?一 跑道地面粗糙 有的跑道在鋪瀝青時,或者選錯了瀝青中石子的規格,或者碾壓得不夠平整,導致路面粗糙。有的跑道使用現成的水泥地,但表面粗糙或不平整。有的室內跑道,為了提高輪胎的...