Repository navigation
Expand file tree
/
Copy pathXcodeObject.m
More file actions
95 lines (88 loc) · 2.26 KB
/
Copy pathXcodeObject.m
File metadata and controls
95 lines (88 loc) · 2.26 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//
// SYXcodeObject.m
// XcodeProjectEditor
//
// Created by Daniel DeCovnick on 4/6/10.
// Copyright 2010 Softyards Software. All rights reserved.
//
#import "XcodeObject.h"
//@interface XcodeObject ( )
//@property(retain) NSDictionary *attrs;
//@end
//Not necessary. Thank you KVC!
@implementation XcodeObject
@synthesize archiver;
@synthesize archiveID;
@synthesize version;
//-(id)objectForKey:(id)aKey
//{
// return [attrs objectForKey:aKey];
//}
//-(void)setObject:(id)anObject forKey:(id)aKey
//{
// [attrs setObject:anObject forKey:aKey];
//}
-(id)initWithHash:(NSDictionary *)hash
{
self = [super init];
if (self)
{
_attrs = [hash mutableCopy] ;
if (![self isMemberOfClass:[XcodeObject class]])
{
NSString *class_name = NSStringFromClass(self.class);
if ([_attrs objectForKey:@"isa"] == nil)
{
[_attrs setObject:class_name forKey:@"isa"];
}
}
}
return self;
}
+(id)newWithArgs:(id)args
{
//if (self != [XcodeObject class])
// {
// return [super newWithArgs:args];
// }
NSString *hash_isa = [[args objectAtIndex:0] objectForKey:@"isa"];
if (hash_isa && NSClassFromString(hash_isa))
{
return [NSClassFromString(hash_isa) newWithArgs:args];
}
return nil;
//return [super newWithArgs:args];
}
//-(NSArray *)attrKeys
//{
// return [self.attrs allKeys];
//}
- (NSDictionary *)attrs
{
return [NSDictionary dictionaryWithObject:NSStringFromClass([self class]) forKey:@"isa"];
// return [NSDictionary dictionaryWithObjectsAndKeys:archiveID, @"archiveID", version, @"version", nil];
}
- (NSDictionary *)hashRepresentation
{
return [NSDictionary dictionaryWithObject:self.attrs forKey:self.archiveID];
}
+(id)fromHash:(NSDictionary *)anObject
{
id ret = [NSClassFromString([anObject objectForKey:@"isa"]) new];
if (!ret)
{
NSLog(@"%@ not implemented yet. If you see this in release, contact the developer immediately, and include your .pbxproj file.", [anObject objectForKey:@"isa"]);
return nil;
}
//historical name; removeObjectIdenticalTo: didn't work.
NSArray *otherKeys = [NSMutableArray arrayWithArray:[anObject allKeys]];
for (NSString *key in otherKeys)
{
if ([key isEqualToString:@"isa"])
continue;
[ret setValue:[anObject objectForKey:key] forKey:key];
}
return ret;
//Some things Ruby does better. This is not one of them.
}
@end