如何打印这个 NSDictionary?

发布于 2024-12-28 08:18:02 字数 2314 浏览 3 评论 0原文

当我打印一些 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;
};
}

NSLog give me this when i print some NSDictionary object. I see, that in this NSDictionary are few NSDictionary objects. i must to send this to UITextView, but this must be one list without {ExifAux}, {Exif}, {IPTC}, {TIFF}. how can i do this?

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;
};
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

¢蛋碎的人ぎ生 2025-01-04 08:18:02

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

- (NSString *)stringOutputForDictionary:(NSDictionary *)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];
}

It's not the most beautiful way, but I guess this should work:

- (NSString *)stringOutputForDictionary:(NSDictionary *)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];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文