Skip to content

Commit

Permalink
增加对BOOL类型的支持
Browse files Browse the repository at this point in the history
  • Loading branch information
walkerwzy committed Sep 18, 2017
1 parent b39eb5e commit dd084c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 2 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,8 @@ function assumeVarType(str, isArray, model) {
let l_str = str.toLowerCase(),
model_type = str, // 类型
var_type = str; // 字段
// if(l_str.includes('string')) model_type = "NSString *";
// 暂时把bool也算作字符串
if(['bool', 'boolean', 'string'].includes(l_str)) model_type = "NSString *";
if(l_str.includes('string')) model_type = "NSString *";
else if(['bool', 'boolean'].includes(l_str)) model_type = "BOOL";
else if(['int', 'integer', 'long'].findIndex(v=>(new RegExp(v,'ig')).test(l_str)) >= 0) model_type = "NSInteger";
else if(l_str == strlist) model_type = "NSArray<NSString *> *"
else if(l_str == intlist) model_type = "NSArray<NSInteger> *";
Expand Down
6 changes: 6 additions & 0 deletions templates/model/template.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ else if(prop.type == 'NSString *') return `
*/
@property (nonatomic, copy) ${prop.type}${prop.name};
`;
else if(prop.type == 'BOOL') return `
/**
* ${prop.des}
*/
@property (nonatomic, assign) ${prop.type} ${prop.name};
`;
return `
/**
* ${prop.des}
Expand Down

0 comments on commit dd084c1

Please sign in to comment.