-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathMorphic.m
81 lines (72 loc) · 1.92 KB
/
Morphic.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//
// Morphic.m
// PlistExplorer
//
// Created by Karsten Kusche on 13.01.10.
// Copyright 2010 Briksoftware.com. All rights reserved.
//
#import "Morphic.h"
#import "PlistExplorer.h"
#import "CrackedUnarchiver.h"
#import "PlistLogger.h"
@implementation Morphic
{
NSMutableDictionary* data;
}
- (id) init
{
self = [super init];
if (self != nil) {
data = [NSMutableDictionary dictionary];
}
return self;
}
- (id)initWithCoder:(NSKeyedUnarchiver*)unarchiver
{
self = [self init];
NSDictionary* blob = [[(CrackedUnarchiver*)unarchiver cracker] blobOfUnarchiver:unarchiver];
for (NSString* key in blob.allKeys)
{
id obj = [blob objectForKey:key];
// if the value is a property-list compatible object, it's something like a number. If it's not compatible, it needs to be decoded seperately
CFTypeID typeID = CFGetTypeID((__bridge CFTypeRef)(obj));
// test if the object is a CFKeyedArchiverUID
if (typeID == 0x29)
{
obj = [unarchiver decodeObjectForKey:key];
if (obj == nil)
{
// nil wouldn't be shown, so use a string @"nil"
obj = @"nil";
}
}
[data setObject: obj forKey:key];
}
return self;
}
- (id)copyWithZone:(NSZone *)zone // needed for some kinds of Core Data "layout" files
{
return [self class]; // not sure if this is the right thing to return, but it avoids crashes
}
- (void)logYourselfLevel:(NSInteger)level using:(PlistLogger*)logger
{
if ([logger tryLogObject:self] == NO) {
// already printed once before
[logger logStringOfObject:@"(recursion)" level:level];
}
else
{
// the information about the object
[logger logStringOfObject:self.className level:level];
// the information about the object's properties
NSArray *keys = [data allKeys];
keys = [keys sortedArrayUsingSelector:@selector(compare:)];
for (NSString* key in keys)
{
id object = [data objectForKey:key];
[logger logKey:key level:level];
[logger logValue:object level:level];
}
}
}
@end