Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

产生UnknownType类型无法识别 #8

Open
solszl opened this issue Feb 27, 2016 · 2 comments
Open

产生UnknownType类型无法识别 #8

solszl opened this issue Feb 27, 2016 · 2 comments

Comments

@solszl
Copy link

solszl commented Feb 27, 2016

当传入值为null的时候。 使用苦力创建的代码,对应的类型为UnknownType? 此时无法识别类型,报错。
烦请修正

测试JSON
{ "location": null }

产生的代码
struct Photo {
let location: UnknownType?
static func fromJSONDictionary(info: [String: AnyObject]) -> Photo? {
let location = info["location"] as? UnknownType
return Photo(location: location)
}
}

错误提示信息为: Use of undeclared type 'UnknownType'

@nixzhu
Copy link
Owner

nixzhu commented Feb 27, 2016

此为故意的设计,因为属性值是null,Coolie无法猜测其类型,所以要由开发者修改生成的模型,指定具体的类型。

另外,某些字面量为字符串的值也很可能需要变换(例如日期),都需要开发者修改模型,Coolie只是帮开发者把最无趣的打字尽可能地减少。

最后是一点建议,在使用中文的时候,要用中文标点,也不需说“烦请修正”这样的话,因为这里面包含了某种义务的要求。

@solszl
Copy link
Author

solszl commented Feb 27, 2016

好的,谢谢你的建议。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants