123456789101112131415161718192021222324252627282930313233343536 |
- //
- // NSArray+Log.m
- // VclustersGemini
- //
- // Created by xd h on 2020/6/24.
- // Copyright © 2020 APPLE. All rights reserved.
- //
- #import "NSArray+Log.h"
- @implementation NSArray (Log)
- - (NSString *)descriptionWithLocale:(nullable id)locale indent:(NSUInteger)level{
-
- NSMutableString *mStr = [NSMutableString string];
- NSMutableString *tab = [NSMutableString stringWithString:@""];
- for (int i = 0; i < level; i++) {
- [tab appendString:@"\t"];
- }
- [mStr appendString:@"(\n"];
- for (int i = 0; i < self.count; i++) {
- NSString *lastSymbol = (self.count == i + 1) ? @"":@",";
- id value = self[i];
- if ([value respondsToSelector:@selector(descriptionWithLocale:indent:)]) {
- [mStr appendFormat:@"\t%@%@%@\n",tab,[value descriptionWithLocale:locale indent:level + 1],lastSymbol];
- } else {
- [mStr appendFormat:@"\t%@%@%@\n",tab,value,lastSymbol];
- }
- }
- [mStr appendFormat:@"%@)",tab];
- return mStr;
-
- }
- @end
|