From dd084c15a6a62ec4c4948a27e60c863b00fe45af Mon Sep 17 00:00:00 2001 From: walker Date: Mon, 18 Sep 2017 10:02:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9BOOL=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 5 ++--- templates/model/template.h | 6 ++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index 1e0cd93..c16bd46 100755 --- a/app.js +++ b/app.js @@ -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 *" else if(l_str == intlist) model_type = "NSArray *"; diff --git a/templates/model/template.h b/templates/model/template.h index ad48ebe..b4adde9 100644 --- a/templates/model/template.h +++ b/templates/model/template.h @@ -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}