zoukankan      html  css  js  c++  java
  • MJExtension简单使用

    1. self.dataArray=  [MJModel mj_objectArrayWithKeyValuesArray:data[@"resultMessage"][@"result"]];//data[@"resultMessage"][@"result"]解析出来的数组
     /* 和上边的方法作用相同
     NSArray *array=data[@"resultMessage"][@"result"];//解析出来的数组
    for (NSDictionary *dic in array) {
    MJModel *modle=[MJModel mj_objectWithKeyValues:dic];
      [self.dataArray addObject:modle]; } */ 2. NSArray * shopsArray = [shopModel objectArrayWithFilename:@"1.plist"]; [self.shops addObjectsFromArray:shopsArray];

    1.简单的字典 --> 模型

    • 核心代码 mj_objectWithKeyValues:
      @interface User : NSObject
      @property (copy, nonatomic) NSString *name;/* 姓名 */
      @property (assign, nonatomic) unsigned int age;/* 年龄 */
      
      @end
      //简单的字典
       NSDictionary *dict_user = @{
                              @"name" : @"Jack",
                              @"age" : @20,
                              };
       User *user = [User mj_objectWithKeyValues:dict_user];
      JSON字符串 --> 模型
    • // 定义一个JSON字符串
       NSString *json = @"{"name":"Jack", "icon":"lufy.png", "age":20}";
       User *user = [User mj_objectWithKeyValues:json];
      

      //其他用法可以参考 http://www.jianshu.com/p/475b28160c89

  • 相关阅读:
    验证码处理 -- 爬虫
    Django知识点总结
    关于sql去重
    tsxt-01
    崔老师爬取top100的源码(会403)
    简单爬取网页源码
    爬取猫眼top100
    python-自动发邮件
    python-装饰器
    Python 爬虫基础Selenium库的使用
  • 原文地址:https://www.cnblogs.com/Lrx-lizi/p/6882338.html
Copyright © 2011-2022 走看看