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

NSDictionary 的 description 返回格式为什么不是{} 而是[]啊 #62

Closed
marujun opened this issue Mar 15, 2016 · 1 comment
Closed
Labels

Comments

@marujun
Copy link

marujun commented Mar 15, 2016

如题,对应的代码如下,dic.count 为0 时是正确的

case YYEncodingTypeNSDictionary: 
case YYEncodingTypeNSMutableDictionary: {
            NSDictionary *dic = (id)model;
            NSMutableString *desc = [NSMutableString new];
            if (dic.count == 0) {
                return [desc stringByAppendingString:@"{}"];
            } else {
                NSArray *keys = dic.allKeys;

                [desc appendFormat:@"[\n"];
                for (NSUInteger i = 0, max = keys.count; i < max; i++) {
                    NSString *key = keys[i];
                    NSObject *value = dic[key];
                    [desc appendString:@"    "];
                    [desc appendFormat:@"%@ = %@",key, ModelDescriptionAddIndent(ModelDescription(value).mutableCopy, 1)];
                    [desc appendString:(i + 1 == max) ? @"\n" : @";\n"];
                }
                [desc appendString:@"]"];
            }
            return desc;
        }
@ibireme ibireme added the bug label Mar 15, 2016
ibireme added a commit that referenced this issue Mar 15, 2016
@ibireme
Copy link
Owner

ibireme commented Mar 15, 2016

Fixed

@ibireme ibireme closed this as completed Mar 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants