-
Notifications
You must be signed in to change notification settings - Fork 2
/
joinPlists.m
35 lines (25 loc) · 954 Bytes
/
joinPlists.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
#import <Foundation/Foundation.h>
int main(int argc, char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
if (argc <= 1)
goto bail;
NSMutableArray * plists = [NSMutableArray array];
for (int i=1; i<argc; ++i) {
[plists addObject:[NSString stringWithFormat:@"%s", argv[i]]];
}
NSMutableDictionary * joined = [NSMutableDictionary dictionary];
for (NSString * plist in plists) {
NSDictionary * plistDict = [NSDictionary dictionaryWithContentsOfFile:plist];
NSDictionary * images = [plistDict objectForKey:@"images"];
[joined addEntriesFromDictionary:images];
}
NSMutableDictionary * joinedPlistDict = [NSMutableDictionary dictionary];
[joinedPlistDict setObject:joined forKey:@"images"];
[joinedPlistDict writeToFile:@"joined.plist" atomically:NO];
goto done;
bail:
fprintf(stderr, "usage: joinPlists [plist1, plist2, ...]\n");
done:
[pool release];
return 0;
}