Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 125 lines (105 sloc) 3.597 kB
720b0e7 @uliwitness Added licensing information to the source files.
authored
1 //
2 // UKNibOwner.m
3 // CocoaTADS
4 //
5 // Created by Uli Kusterer on 13.11.2004.
6 // Copyright 2004 Uli Kusterer.
7 //
8 // This software is provided 'as-is', without any express or implied
9 // warranty. In no event will the authors be held liable for any damages
10 // arising from the use of this software.
11 //
12 // Permission is granted to anyone to use this software for any purpose,
13 // including commercial applications, and to alter it and redistribute it
14 // freely, subject to the following restrictions:
15 //
16 // 1. The origin of this software must not be misrepresented; you must not
17 // claim that you wrote the original software. If you use this software
18 // in a product, an acknowledgment in the product documentation would be
19 // appreciated but is not required.
20 //
21 // 2. Altered source versions must be plainly marked as such, and must not be
22 // misrepresented as being the original software.
23 //
24 // 3. This notice may not be removed or altered from any source
25 // distribution.
26 //
dc5be1c Initial check-in.
uli authored
27
28 // -----------------------------------------------------------------------------
29 // Headers:
30 // -----------------------------------------------------------------------------
31
32 #import "UKNibOwner.h"
33
34
35 @implementation UKNibOwner
36
37 // -----------------------------------------------------------------------------
38 // init:
39 // Create this object and load NIB file. Note that for subclasses, this
40 // is called before your subclass has been fully constructed. I know this
41 // sucks, because awakeFromNib can't rely on stuff that's done in the
42 // constructor. I'll probably change this eventually.
43 //
44 // REVISIONS:
45 // 2004-12-23 UK Documented.
46 // -----------------------------------------------------------------------------
47
48 -(id) init
49 {
6290385 UKNibOwner can be created for different NIBs and owners. Can release …
uli authored
50 return [self initWithNibName: [self nibFilename] owner: self];
51 }
52
53 -(id) initWithNibName: (NSString*)nibName
54 {
55 return [self initWithNibName: nibName owner: self];
56 }
57
58 -(id) initWithNibName: (NSString*)nibName owner: (id)owner
59 {
dc5be1c Initial check-in.
uli authored
60 if( (self = [super init]) )
61 {
aad4c7f @uliwitness Make UKNibOwner work with classes in frameworks/plug-ins as well
authored
62 NSBundle* mainB = [NSBundle bundleForClass: [self class]];
6290385 UKNibOwner can be created for different NIBs and owners. Can release …
uli authored
63 if( nibName )
6c28639 @uliwitness Shut up deprecation warning.
authored
64 {
65 [mainB loadNibNamed: nibName owner: owner topLevelObjects: &topLevelObjects];
c91cdc2 @uliwitness Oops. Overlooked a dangling pointer when updating this to the new XIB…
authored
66 [topLevelObjects retain];
6c28639 @uliwitness Shut up deprecation warning.
authored
67 }
6290385 UKNibOwner can be created for different NIBs and owners. Can release …
uli authored
68 if( nibName && [topLevelObjects count] == 0 )
dc5be1c Initial check-in.
uli authored
69 {
aad4c7f @uliwitness Make UKNibOwner work with classes in frameworks/plug-ins as well
authored
70 mainB = [NSBundle mainBundle];
71 if( nibName )
6c28639 @uliwitness Shut up deprecation warning.
authored
72 [mainB loadNibNamed: nibName owner: owner topLevelObjects: &topLevelObjects];
c91cdc2 @uliwitness Oops. Overlooked a dangling pointer when updating this to the new XIB…
authored
73 [topLevelObjects retain];
aad4c7f @uliwitness Make UKNibOwner work with classes in frameworks/plug-ins as well
authored
74 }
75 if( nibName && [topLevelObjects count] == 0 )
76 {
6290385 UKNibOwner can be created for different NIBs and owners. Can release …
uli authored
77 NSLog(@"%@: Couldn't find NIB file \"%@.nib\".", NSStringFromClass([self class]), nibName);
dc5be1c Initial check-in.
uli authored
78 [self autorelease];
79 return nil;
80 }
6290385 UKNibOwner can be created for different NIBs and owners. Can release …
uli authored
81
82 if( owner != self )
83 [self awakeFromNib];
dc5be1c Initial check-in.
uli authored
84 }
85
86 return self;
87 }
88
89
90 -(void) dealloc
91 {
92 [topLevelObjects release];
93 topLevelObjects = nil;
94
95 [super dealloc];
96 }
97
98
6290385 UKNibOwner can be created for different NIBs and owners. Can release …
uli authored
99 -(void) releaseTopLevelObjects
100 {
1a03e3e Added a proxyController outlet so you can set up an NSObjectControlle…
uli authored
101 [proxyController setContent: nil];
6290385 UKNibOwner can be created for different NIBs and owners. Can release …
uli authored
102 [topLevelObjects release];
103 topLevelObjects = nil;
104 }
105
dc5be1c Initial check-in.
uli authored
106
107 // -----------------------------------------------------------------------------
108 // nibFilename:
109 // Return the filename (minus ".nib" suffix) for the NIB file to load.
110 // Note that, if you subclass this, it will use the subclass's name, and
111 // if you subclass that, the sub-subclass's name. So, you *may* want to
112 // override this to return a constant string if you don't expect subclasses
113 // to have their own similar-but-different NIB file.
114 //
115 // REVISIONS:
116 // 2004-12-23 UK Documented.
117 // -----------------------------------------------------------------------------
118
119 -(NSString*) nibFilename
120 {
121 return NSStringFromClass([self class]);
122 }
123
124 @end
Something went wrong with that request. Please try again.