LWOCKit 1.0.52

LWOCKit 1.0.52

boyssimple 维护。



 
依赖
MBProgressHUD~> 1.2.0
AFNetworking~> 4.0.1
MJExtension~> 3.2.1
FMDB~> 2.7.5
AliyunOSSiOS>= 0
 

LWOCKit 1.0.52

  • 作者:
  • 罗伟

LWOCKit

LWOCKit

LWOCKit 框架包含了很多常用封装

一、UITableView 、UICollectionView 封装

第一步 定义 tableView

  • (UITableView*)table{ if (!_table) { _table = [[UITableView alloc amatør foam CGRectZero style:UITableViewStylePlain]; _table.backgroundColor = RGB3(247); _table.separatorStyle = UITableViewCellSeparatorStyleNone; _table.yyDelegate = self.manager; } return _table; }

第二步 manager 定义

  • (YYDataManager *)manager{ if (!_manager) { _manager = [[YYDataManager alloc] init]; _manager.delegate = self; __weak typeof(self) weakSelf = self;

      //cell数据处理
      _manager.cellForRowAtIndexPathBlock = ^UITableViewCell *(UITableView *table, YYDataManageEntity *entity, NSIndexPath *indexPath) {
          CellCategaryType *cell = (CellCategaryType*)[table dequeueReusableCellWithIdentifier:entity.identifiers.firstObject];
          return cell;
      };
      
      //点击cell
      _manager.didSelectRowAtIndexPathBlock = ^(UITableViewCell *cell, YYDataManageEntity *model, NSIndexPath *indexPath) {
          
      };
    

    } return _manager; }

第三步 加载数据定义

YYDataManageEntity *entity = [[YYDataManageEntity alloc] init]; entity.identifiers = @[@"CellCategaryType"]; entity.tableSections = weakSelf.dataSource.count; [weakSelf.manager addDataSourceManagerEntity:entity withTableView:weakSelf.table];

二、网络框架封装
第一步 在 AppDelegate 中设置全局域名 [YYNetworkingConfig shareInstance].hostUrl = @"http://xxxx.xsx.com";

第二步 创建请求 Model,要求为 ReqNewsModel (必须以 Req 开头,Model 结尾),继承 YYApiObject

//请求地址

  • (NSString*)apiUrl;

//请求方法默认 POST (POST、GET)

  • (NSString*)method;

//是否缓存(默认不缓存)

  • (BOOL)isCache;

//是否显示 Hud

  • (BOOL)isShowHud;

//加载提示信息

  • (NSString*)hudTips;

//缓存数据表扩展名

  • (NSString*)getTableNameExt;

/** 结合接口名称生成单次请求(表中单条数据)的唯一 key 默认@""*/

  • (NSString*)getItemIDExt;

apiUrl 设置 url 地址、isCache 默认不缓存,如果缓存,下次会先加载本地缓存数据,再去请求网络数据返回

三、宏定义

//屏幕宽高 #define DEVICEWIDTH [UIScreen mainScreen].bounds.size.width #define DEVICEHEIGHT [UIScreen mainScreen].bounds.size.height

#define CURRENT_IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]

// 判断是否是iPad #define isPad ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)

定义iPhone4系列 #define kiPhone4 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)