前言:字典轉(zhuǎn)模型的常用第三方框架有:
1.Mantle:所有模型必須繼承自MTModel。
2.JSONModel:所有模型都必須繼承自JSONModel冬殃。
3.MJExtension:不需要強(qiáng)制繼承任何類谣拣。( 最關(guān)鍵是我們中國人寫的募寨,還得到了更多的delveloper一起完善補(bǔ)充)
本文主要介紹MJExtension:一個ChineseCoder創(chuàng)作的框架。
先附上地址:https://github.com/CoderMJLee/MJExtension
如果有時間可以研究一下源代碼
使用起來非常方便森缠。
下面將舉例說明:
- 第一個例子:只用一行代碼拔鹰,懶加載 將tgs.plist中的數(shù)據(jù)轉(zhuǎn)換成 數(shù)組(字典)tgs
只需要填上文件名即可
@interface ViewController ()
/** 所有的團(tuán)購數(shù)據(jù) */
@property (nonatomic, strong) NSArray *tgs;
@end
@implementation ViewController
- (NSArray *)tgs
{
if (!_tgs) {
_tgs = [BQTg mj_objectArrayWithFilename:@"tgs.plist"];
}
return _tgs;
}