Skip navigation.
 
mlRe: Bypassing Interface Builder
FROM : Graham Cox
DATE : Thu May 15 02:45:04 2008

On 15 May 2008, at 10:15 am, Johnny Lundy wrote:

> Hi,
>
> On this topic, when I drag an object out of the Library and set its 
> class, IB sets the label of the object to the Class Name. Since this 
> is an instance of the class, and not the Class Object itself, why is 
> the name capitalized? And if I want to refer by name to that 
> instance in my code, what is the name of the instance?


The name of an object in IB is not accessible to your code, generally 
speaking. It's just a convenience so you can tell things apart in IB. 
You can change that label in IB by editing it directly, but it's not 
important. ****It certainly doesn't mean that this is the variable 
name for that object instance.****

> Say I drag out an object and set its class to MyClass. IB dutifully 
> names the object MyClass also. So in my code if I code [MyClass 
> somemessage], does that message go to the Class Object or to the 
> instance made in IB? If to the Class Object, how do I code to refer 
> to the instance?


The name is irrelevant (see above). You refer to it by having an 
IBOutlet which is connected to that instance. If you are talking about 
class methods, then there's no ambiguity anyway - there are no 
"instances" of class methods, by definition - so messages to the class 
go to the, err... class.

> Also, I found out that IB will not let me make 2 instances of the 
> same Class. In code, I could say myClassInstance1 = [MyClass new]; 
> and MyClassInstance2 = [MyClass new];, but apparently not in IB.


Sure you can. Not sure why you think this, but maybe the confusion 
about the IB name is misleading you. Once you realise that the name 
shown in IB has no significance whatsoever, it may release you from 
this confusion.

> This has been a mystery to me for six years now.


That is indeed a long time to be this muddled. My sympathies.

> Also, the documentation only says about File's Owner that it is the 
> object that loaded the nib file. What is that object, if my nib file 
> just gets loaded at application launch?
>


It depends. It's the file's (nib's) owner. If you are talking about 
MainMenu.nib, its owner is the application instance. For typical 
document nibs, it's the NSDocument instance. For others, it's whatever 
you pass as "owner" in the NSBundle class method +loadNibNamed:owner:



hth,


G.

Related mailsAuthorDate
mlBypassing Interface Builder colo May 14, 16:36
mlRe: Bypassing Interface Builder I. Savant May 14, 17:11
mlRe: Bypassing Interface Builder colo May 14, 17:35
mlRe: Bypassing Interface Builder I. Savant May 14, 17:43
mlRe: Bypassing Interface Builder Andy Lee May 14, 17:50
mlRe: Bypassing Interface Builder colo May 14, 17:53
mlRe: Bypassing Interface Builder I. Savant May 14, 17:58
mlRe: Bypassing Interface Builder David Wilson May 14, 17:59
mlRe: Bypassing Interface Builder I. Savant May 14, 18:01
mlRe: Bypassing Interface Builder I. Savant May 14, 18:05
mlRe: Bypassing Interface Builder Gregory Weston May 14, 18:06
mlRe: Bypassing Interface Builder glenn andreas May 14, 18:13
mlRe: Bypassing Interface Builder Wayne Packard May 14, 18:26
mlRe: Bypassing Interface Builder Andy Lee May 14, 18:37
mlRe: Bypassing Interface Builder Stefan Werner May 14, 18:46
mlRe: Bypassing Interface Builder Bill Bumgarner May 14, 19:00
mlRe: Bypassing Interface Builder Boyd Collier May 14, 19:34
mlRe: Bypassing Interface Builder colo May 14, 19:37
mlRe: Bypassing Interface Builder Julius Guzy May 14, 22:05
mlRe: Bypassing Interface Builder Torsten Curdt May 14, 22:49
mlRe: Bypassing Interface Builder colo May 15, 00:53
mlRe: Bypassing Interface Builder Graham Cox May 15, 01:26
mlRe: Bypassing Interface Builder Graham Cox May 15, 01:41
mlRe: Bypassing Interface Builder colo May 15, 02:14
mlRe: Bypassing Interface Builder Johnny Lundy May 15, 02:15
mlRe: Bypassing Interface Builder Graham Cox May 15, 02:29
mlRe: Bypassing Interface Builder I. Savant May 15, 02:43
mlRe: Bypassing Interface Builder Graham Cox May 15, 02:45
mlRe: Bypassing Interface Builder I. Savant May 15, 02:51
mlRe: Bypassing Interface Builder I. Savant May 15, 02:54
mlRe: Bypassing Interface Builder Andy Lee May 15, 03:02
mlRe: Bypassing Interface Builder Graham Cox May 15, 03:02
mlRe: Bypassing Interface Builder Andy Lee May 15, 03:06
mlRe: Bypassing Interface Builder I. Savant May 15, 03:07
mlRe: Bypassing Interface Builder Andy Lee May 15, 03:08
mlRe: Bypassing Interface Builder I. Savant May 15, 03:09
mlRe: Bypassing Interface Builder I. Savant May 15, 03:15
mlRe: Bypassing Interface Builder Andy Lee May 15, 03:29
mlRe: Bypassing Interface Builder Julius Guzy May 15, 03:35
mlRe: Bypassing Interface Builder I. Savant May 15, 03:37
mlRe: Bypassing Interface Builder Johnny Lundy May 15, 04:33
mlRe: Bypassing Interface Builder Julius Guzy May 15, 04:36
mlRe: Bypassing Interface Builder Johnny Lundy May 15, 04:54
mlRe: Bypassing Interface Builder Graham Cox May 15, 05:43
mlRe: Bypassing Interface Builder Uli Kusterer May 15, 07:50
mlRe: Bypassing Interface Builder Uli Kusterer May 15, 07:55
mlRe: Bypassing Interface Builder Uli Kusterer May 15, 08:15
mlcocoa mentoring (was Re: Bypassing Interface Builder) Torsten Curdt May 15, 15:36
mlRe: cocoa mentoring (was Re: Bypassing Interface Builder) Paul Bruneau May 15, 15:47
mlRe: cocoa mentoring (was Re: Bypassing Interface Builder) Uli Kusterer May 15, 16:08
mlcocoaheads frankfurt (was Re: cocoa mentoring) Torsten Curdt May 15, 16:44
mlRe: cocoa mentoring (was Re: Bypassing Interface Builder) Torsten Curdt May 15, 16:51
mlRe: Bypassing Interface Builder Andy Lee May 15, 17:11
mlRe: Bypassing Interface Builder Johnny Lundy May 15, 18:40
mlRe: cocoa mentoring (was Re: Bypassing Interface Builder) Dennis Munsie May 15, 19:34
mlRe: Bypassing Interface Builder Paul Sargent May 15, 20:07
mlRe: Bypassing Interface Builder Uli Kusterer May 15, 20:48
mlRe: Bypassing Interface Builder Shawn Erickson May 15, 22:20
mlRe: Bypassing Interface Builder Shawn Erickson May 15, 22:30
mlRe: Bypassing Interface Builder Johnny Lundy May 15, 22:32
mlRe: cocoa mentoring (was Re: Bypassing Interface Builder) Torsten Curdt May 15, 23:03