Permalink
Browse files

Added recursive management of view hierarchies

  • Loading branch information...
1 parent 6afc75e commit 78107cae0181a2c7a77b869198780dda8bcc9c36 Adrian Kosmaczewski committed Mar 14, 2009
Showing with 24 additions and 1 deletion.
  1. +24 −1 NibProcessor.m
View
@@ -22,6 +22,7 @@ @interface NibProcessor (Private)
- (void)getDictionaryFromNIB;
- (void)process;
+- (void)parseChildren:(NSDictionary *)dict ofCurrentView:(int)currentView;
@end
@@ -111,7 +112,6 @@ - (void)process
{
// NSDictionary *nibClasses = [dict objectForKey:@"com.apple.ibtool.document.classes"];
// NSDictionary *nibConnections = [dict objectForKey:@"com.apple.ibtool.document.connections"];
- // NSArray *nibHierarchy = [dict objectForKey:@"com.apple.ibtool.document.hierarchy"];
NSDictionary *nibObjects = [dictionary objectForKey:@"com.apple.ibtool.document.objects"];
NSMutableDictionary *objects = [[NSMutableDictionary alloc] init];
@@ -185,8 +185,31 @@ - (void)process
[output appendString:@"\n"];
}
+ // Now that the objects are created, recreate the hierarchy of the NIB
+ NSArray *nibHierarchy = [dictionary objectForKey:@"com.apple.ibtool.document.hierarchy"];
+ for (NSDictionary *item in nibHierarchy)
+ {
+ int currentView = [[item objectForKey:@"object-id"] intValue];
+ [self parseChildren:item ofCurrentView:currentView];
+ }
+
[objects release];
objects = nil;
}
+- (void)parseChildren:(NSDictionary *)dict ofCurrentView:(int)currentView
+{
+ NSArray *children = [dict objectForKey:@"children"];
+ if (children != nil)
+ {
+ for (NSDictionary *subitem in children)
+ {
+ int subview = [[subitem objectForKey:@"object-id"] intValue];
+ [self parseChildren:subitem ofCurrentView:subview];
+ [output appendFormat:@"[view%d addSubview:view%d];\n", currentView, subview];
+ [output appendFormat:@"[view%d release];\n", subview];
+ }
+ }
+}
+
@end

0 comments on commit 78107ca

Please sign in to comment.