Traverse the multidimensional nsdictionary after JSON is converted to nsdictionary

From , 5 Years ago, written in Objective-C, viewed 77 times.
URL https://pastebin.vip/view/29fdff89
  1. - (NSString *)stringFormDict:(NSDictionary*)dict
  2.  {
  3.      NSMutableString *str = [NSMutableString string];
  4.      NSArray *keys = [dict allKeys];
  5.      for (NSString *key in keys) {
  6.          if ([[dict objectForKey:key] isKindOfClass:[NSDictionary class]]) {
  7.              id obj = [dict objectForKey:key];
  8.              [str appendFormat:@"\n%@: %@",key,[self stringFormDict:obj]];
  9.          }else if ([[dict objectForKey:key] isKindOfClass:[NSArray class]]){
  10.              [str appendFormat:@"\n%@:",key];
  11.              for (id obj in [dict objectForKey:key]) {
  12.                  [str appendFormat:@"\n%@",[self stringFormDict:obj]];
  13.              }
  14.          }else{
  15.              [str appendFormat:@"\n%@: %@",key,[dict objectForKey:key]];
  16.          }
  17.      }
  18.      return str;
  19.  }
  20. //objectc/5093

Reply to "Traverse the multidimensional nsdictionary after JSON is converted to nsdictionary"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website