-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathGKNibViewController.m
More file actions
102 lines (86 loc) · 2.48 KB
/
GKNibViewController.m
File metadata and controls
102 lines (86 loc) · 2.48 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
96
97
98
99
100
101
102
#import "GKNibViewController.h"
@interface GKNibViewController()
@property (ARC_PROP_OUTLET) IBOutlet id outletView;
@property (ARC_PROP_STRONG) NSArray* topLevelObjects;
@property (assign,readwrite) NSInteger constructed;
@property (assign) BOOL constructedSuccess;
@end
@implementation GKNibViewController
ARC_SYNTHESIZEOUTLET(outletViewHolder);
ARC_SYNTHESIZEOUTLET(outletView);
ARC_SYNTHESIZE(topLevelObjects,__topLevelObjects);
ARC_SYNTHESIZE(constructed,__constructed);
- (void) dealloc {
ARC_DEALLOC_NIL(self.topLevelObjects);
ARC_SUPERDEALLOC(self);
}
- (NSString*)nibLoadNameDefault {
return NSStringFromClass([self class]);
}
- (BOOL)nibLoadConstructed {
return (self.constructed!=0) && REQUIRED_DEBUG(self.topLevelObjects!=nil);
}
- (BOOL)nibLoadOnThisVersionOfOSX {
return YES;
}
-(BOOL) loadObjectGraphWithNibName:(NSString*)nibName
{ // NSLOG(@"NSUIViewNibbler:instantiateObjectGraphWithNibName:%@\n", nibName);
BOOL result = NO;
if (REQUIRED_DEBUG(self.constructed == 0))
{
self.constructed += 1;
self.topLevelObjects = nil;
if (self.nibLoadOnThisVersionOfOSX && REQUIRED_DEBUG(self.outletViewHolder!=nil))
{
@try
{
NSNib* classNib = [[NSNib alloc] initWithNibNamed:nibName bundle:nil];
if (REQUIRED_DEBUG(classNib!=nil))
{
NSArray* receivesTopLevelObjects = nil;
if (REQUIRED_DEBUG([classNib instantiateNibWithOwner:self topLevelObjects:&receivesTopLevelObjects]))
{
self.topLevelObjects = receivesTopLevelObjects;
result = REQUIRED_DEBUG(receivesTopLevelObjects!=nil) && REQUIRED_DEBUG(self.outletView!=nil);
}
ARC_RELEASE(classNib);
}
}
@catch (NSException* x)
{
NSLOG_METHOD(x);
}
}
}
return result;
}
#if TARGET_OS_PHONE
- (void) awakeFromNibInstallSubview:(UIView*)view {
#error
}
#else
- (void) awakeFromNibInstallSubview:(NSView*)outletView {
NSRect initialSubViewFrame = [outletView frame];
[self.outletViewHolder addSubview:outletView];
[outletView resizeWithOldSuperviewSize:initialSubViewFrame.size];
[outletView setNeedsDisplay:YES];
}
#endif
- (void) awakeFromNib {
if (self.constructed==0)
{
if (REQUIRED_DEBUG([self loadObjectGraphWithNibName:self.nibLoadNameDefault]))
{
if (REQUIRED_DEBUG(self.outletViewHolder!=nil) && REQUIRED_DEBUG(self.outletView!=nil))
{
[self awakeFromNibInstallSubview:self.outletView];
[self nibLoadAwakeFromNibOnce];
}
}
}
}
- (void) nibLoadAwakeFromNibOnce {
NSLOG_METHOD(self);
REQUIRED_DEBUG(self.outletView!=nil);
}
@end