• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

objective-c - 如何打印这个 NSDictionary?

[复制链接]
菜鸟教程小白 发表于 2022-12-13 10:52:01 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

当我打印一些 NSDictionary 对象时,NSLog 会给我这个。我明白了,在这个 NSDictionary 中很少有 NSDictionary 对象。我必须将它发送到 UITextView,但这必须是一个没有 {ExifAux}、{Exif}、{IPTC}、{TIFF} 的列表。我该怎么做?

2012-01-21 13:33:23.818 foto-edytor[7838:17903] {
ColorModel = RGB;
DPIHeight = 240;
DPIWidth = 240;
Depth = 8;
PixelHeight = 900;
PixelWidth = 598;
"{ExifAux}" =     {
    ImageNumber = 5280;
    LensID = 159;
    LensInfo =         (
        35,
        35,
        "1.8",
        "1.8"
    );
    LensModel = "35.0 mm f/1.8";
    SerialNumber = 6055523;
};
"{Exif}" =     {
    ApertureValue = "3.356144";
    BodySerialNumber = 6055523;
    ColorSpace = 1;
    ComponentsConfiguration =         (
        1,
        2,
        3,
        0
    );
    Contrast = 0;
    CustomRendered = 0;
    DateTimeDigitized = "2011:11:12 11:54:18";
    DateTimeOriginal = "2011:11:12 11:54:18";
    DigitalZoomRatio = 1;
    ExifVersion =         (
        2,
        2,
        1
    );
    ExposureBiasValue = "-1.333333";
    ExposureMode = 0;
    ExposureProgram = 3;
    ExposureTime = "0.01666667";
    FNumber = "3.2";
    FileSource = 3;
    Flash = 0;
    FlashPixVersion =         (
        1,
        0
    );
    FocalLenIn35mmFilm = 52;
    FocalLength = 35;
    GainControl = 1;
    ISOSpeedRatings =         (
        400
    );
    LensModel = "35.0 mm f/1.8";
    LensSpecification =         (
        35,
        35,
        "1.8",
        "1.8"
    );
    LightSource = 0;
    MaxApertureValue = "1.6";
    MeteringMode = 2;
    PixelXDimension = 1442971648;
    PixelYDimension = "-2080178176";
    Saturation = 0;
    SceneCaptureType = 0;
    SceneType = 1;
    SensingMethod = 2;
    Sharpness = 0;
    ShutterSpeedValue = "5.906891";
    SubjectDistRange = 0;
    SubjectDistance = "1.41";
    SubsecTimeDigitized = 25;
    SubsecTimeOriginal = 25;
    UserComment = SZULC;
    WhiteBalance = 0;
};
"{IPTC}" =     {
    Byline = "SZULC TOMASZ";
    CopyrightNotice = "SZULC TOMASZ";
};
"{TIFF}" =     {
    Artist = "SZULC TOMASZ";
    Copyright = "SZULC TOMASZ";
    DateTime = "2012:01:20 17:50:58";
    Make = "NIKON CORPORATION";
    Model = "NIKON D300S";
    ResolutionUnit = 2;
    Software = "Ver.1.01";
    XResolution = 240;
    YResolution = 240;
    "_YCbCrPositioning" = 1;
};
}



Best Answer-推荐答案


这不是最漂亮的方式,但我想这应该可行:

- (NSString *)stringOutputForDictionaryNSDictionary *)inputDict {
   NSMutableString * outputString = [NSMutableString stringWithCapacity:256];

   NSArray * allKeys = [inputDict allKeys];

   for (NSString * key in allKeys) {
        if ([[inputDict objectForKey:key] isKindOfClass:[NSDictionary class]]) {
            [outputString appendString: [self stringOutputForDictionary: (NSDictionary *)inputDict]];
        }
        else {
        [outputString appendString: key];
        [outputString appendString: @": "];
        [outputString appendString: [[inputDict objectForKey: key] description]];
        }
    [outputString appendString: @"\n"];
    }

    return [NSString stringWithString: outputString];
}

关于objective-c - 如何打印这个 NSDictionary?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8953027/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap