-
Notifications
You must be signed in to change notification settings - Fork 917
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
关于testCustom增加部分json导致其测试失败问题 #112
Comments
感谢提出问题,这里是在处理特殊的 key path (例如 ".ext" "a..b" "a.b.." ) 不够完善,已修复:c53f3bb |
我今天又针对yy_modelSetWithDictionary方法中的 |
只是能尽量减少外面的遍历次数,但这个其实优化空间是很有限的。 |
@ibireme 或许遇到在通过 |
@molon 我也是没见过@".etx"这样的key... |
如果真有这种 key 那还挺头疼的。。正向反向转换都不太好处理。。 |
修改 testCustom方法中的
json = @"{\".ext\":\"Apple\"}";
为
json = @"{\".ext\":\"Apple\", \"name\":\"Apple\", \"count\":\"10\", \"desc1\":\"Apple\", \"desc2\":\"Apple\", \"desc3\":\"Apple\", \"desc4\":\"Apple\", \"modelID\":\"Apple\"
这样执行yy_modelSetWithDictionary的时候,因为modelMeta->_keyMappedCount=8, CFDictionaryGetCount((CFDictionaryRef)dic))=7,所以不会执行第一个if分支中的
CFDictionaryApplyFunction((CFDictionaryRef)dic, ModelSetWithDictionaryFunction, &context);
而是执行if的else分支
CFArrayApplyFunction((CFArrayRef)modelMeta->_allPropertyMetas, CFRangeMake(0, modelMeta->_keyMappedCount), ModelSetWithPropertyMetaArrayFunction, &context);
在回调函数中ModelSetWithPropertyMetaArrayFunction中,想利用YYValueForKeyPath获取
@{@".ext" : @"Apple"}
的值,其结果是失败的。虽然我不是很明白
modelMeta->_keyMappedCount >= CFDictionaryGetCount((CFDictionaryRef)dic)
这个if分支的带来的好处(感觉即使只有第二个分支,除了testCustom出现以上的错误外,其他测试都能过,不过可能也有性能方面的考虑吧),但是在我说的上面那种情况下,测试结果的确是失败的。不知道这种情况是不是正常的呢?The text was updated successfully, but these errors were encountered: