All Projects → indulgeIn → Ybmodelfile

indulgeIn / Ybmodelfile

Licence: mit
根据 JSON 自动生成 Model 文件(数据模型)

Projects that are alternatives of or similar to Ybmodelfile

Capslock Plus
An efficiency tool that provides various functions by enhancing the Caps Lock key into a modifier key.
Stars: ✭ 650 (+211%)
Mutual labels:  efficiency
Freqbench
Comprehensive CPU frequency performance/power benchmark
Stars: ✭ 65 (-68.9%)
Mutual labels:  efficiency
Eemeter
An open source python package for implementing and developing standard methods for calculating normalized metered energy consumption and avoided energy use.
Stars: ✭ 134 (-35.89%)
Mutual labels:  efficiency
Ostrio Analytics
📊 Visitor's analytics tracking code for ostr.io service
Stars: ✭ 9 (-95.69%)
Mutual labels:  efficiency
Ngautocomplete
Light-weight autocomplete component for Angular.
Stars: ✭ 52 (-75.12%)
Mutual labels:  auto-complete
Xseries
Library for cross-version Minecraft Bukkit support and various efficient API methods.
Stars: ✭ 109 (-47.85%)
Mutual labels:  efficiency
Python Mss
An ultra fast cross-platform multiple screenshots module in pure Python using ctypes.
Stars: ✭ 582 (+178.47%)
Mutual labels:  efficiency
Ghostskb
Smart input method switcher like a ghost
Stars: ✭ 186 (-11%)
Mutual labels:  efficiency
Sublime Phpck
PHP completions for Sublime Text.
Stars: ✭ 58 (-72.25%)
Mutual labels:  auto-complete
Deadline
A simple TODO with countdown timer
Stars: ✭ 134 (-35.89%)
Mutual labels:  efficiency
Go Benchmark App
Application for HTTP benchmarking via different rules and configs
Stars: ✭ 21 (-89.95%)
Mutual labels:  efficiency
Hayaku
Fuzzy abbreviations, support for preprocessors (Sass, Less, Stylus) and a lot of other features in easily configurable set of tools for writing CSS faster
Stars: ✭ 973 (+365.55%)
Mutual labels:  auto-complete
Strcf
Learning Spatial-Temporal Regularized Correlation Filters for Visual Tracking (CVPR 2018)
Stars: ✭ 127 (-39.23%)
Mutual labels:  efficiency
Void
terminal-based personal organizer
Stars: ✭ 831 (+297.61%)
Mutual labels:  efficiency
Gradlr
🌀 Fastest auto complete for gradle tasks
Stars: ✭ 151 (-27.75%)
Mutual labels:  auto-complete
Steward
A command launcher for Chrome
Stars: ✭ 617 (+195.22%)
Mutual labels:  efficiency
Server Tech Tree
服务端软件技术树:服务端主流技术九大分类和全景图
Stars: ✭ 106 (-49.28%)
Mutual labels:  efficiency
Disableautofill.js
Disable form auto-fill and auto-complete functions.
Stars: ✭ 201 (-3.83%)
Mutual labels:  auto-complete
Ac Php
emacs auto-complete & company-mode for php
Stars: ✭ 157 (-24.88%)
Mutual labels:  auto-complete
Auto Complete
Emacs auto-complete package
Stars: ✭ 1,622 (+676.08%)
Mutual labels:  auto-complete

YBModelFile

Cocoapods  Cocoapods  License 

根据 JSON 自动生成 Model 文件(数据模型)

技术原理博客:iOS 效率工具:自动生成 Model 文件

注意:仅在模拟器下运行有效

特性

  • 一句代码自动生成数据模型文件
  • 支持 YYModel / MJExtension 的自动映射
  • 自动过滤转换类名和属性名
  • 自动实现 NSCopying / NSCoding 协议方法
  • 支持文件创建策略:一个类一组文件或并为一组文件
  • 支持属性类型的过滤策略
  • 算法处理模块粒度小且面向协议,可自由定制局部算法

安装

CocoaPods

  1. 在 Podfile 中添加 pod 'YBModelFile', :configurations => ['Debug']
  2. 执行 pod installpod update
  3. 导入 <YBModelFile/YBModelFile.h>

若搜索不到库,可使用 rm ~/Library/Caches/CocoaPods/search_index.json 移除本地索引然后再执行安装,或者更新一下 CocoaPods 版本。

手动导入

  1. 下载 YBModelFile 文件夹所有内容并且拖入你的工程中。
  2. 导入 YBModelFile.h

用法

可下载 DEMO 查看示例。

基本使用

NSString *name = ...;   //主 Model 文件名字
id data = ...;          //json数据
[YBModelFile createFileWithName:name data:data];

一句代码调用过后,工具会自动在桌面上创建一个 YBModelFile-Workspace 文件夹,之后所有自动创建的 Model 文件会存储在该文件夹下,只需要将它们拖入工程就能直接使用。

当然,可以使用-createFileWithName:data:path:方法中的path指定工作空间的存储路径。

字典转模型框架设置

由于工具会自动进行属性和数组元素的映射,你需要指定工程使用的字典转模型框架,目前支持 YYModel 和 MJExtension。

[YBMFConfig shareConfig].framework = YBMFFrameworkYY;

NSCoding 和 NSCopying 协议

NSCoding 和 NSCopying 协议是否实现可以指定:

[YBMFConfig shareConfig].needCoding = NO;
[YBMFConfig shareConfig].needCopying = NO;

属性和方法之间是否空行

工具提供简单的定制:

[YBMFConfig shareConfig].fileHHandler.ybmf_skipLine = YES;
[YBMFConfig shareConfig].fileMHandler.ybmf_skipLine = YES;

类名公用后缀

默认情况下,类名公用后缀为Model,可以自行定制:

[YBMFConfig shareConfig].fileSuffix = @"File";

属性忽略类型

在构建 Model 时,往往需要过滤掉一些类型,比如需要使用NSString提到NSNumber,过滤掉字典中的可变类型。这些都可以通过一个多选枚举来配置,过滤的类型工具会使用更宽泛的类型来处理。

[YBMFConfig shareConfig].ignoreType = YBMFIgnoreTypeAllDigital | YBMFIgnoreTypeMutable;

文件划分策略

目前支持两种策略,一种是所有类都放到一组文件 (.h/.m),一种是一个类对应一组文件:

[YBMFConfig shareConfig].filePartitionMode = YBMFFilePartitionModeApart;

处理算法自定义

对于工具中的算法,都是通过一些类来处理,默认有实现,如果需要自定义,只需要实现对应的协议并且赋值给配置单例:

/** 名字处理器 */
@property (nonatomic, strong) id<YBMFNameHandler> nameHander;
/** 文件头部注解处理器 */
@property (nonatomic, strong) id<YBMFFileNoteHandler> fileNoteHander;
/** .h文件代码处理器 */
@property (nonatomic, strong) id<YBMFFileHHandler> fileHHandler;
/** .m文件代码处理器 */
@property (nonatomic, strong) id<YBMFFileMHandler> fileMHandler;
/** 节点作为父节点的属性时 Code 格式处理器 */
@property (nonatomic, strong) id<YBMFCodeForParentHandler> codeForParentHandler;
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].