• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Bypassing Interface Builder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bypassing Interface Builder


  • Subject: Re: Bypassing Interface Builder
  • From: Graham Cox <email@hidden>
  • Date: Thu, 15 May 2008 10:45:04 +1000


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. _______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Bypassing Interface Builder
      • From: Andy Lee <email@hidden>
    • Re: Bypassing Interface Builder
      • From: "I. Savant" <email@hidden>
References: 
 >Re: Bypassing Interface Builder (From: Johnny Lundy <email@hidden>)

  • Prev by Date: Re: Bypassing Interface Builder
  • Next by Date: Re: Bypassing Interface Builder
  • Previous by thread: Re: Bypassing Interface Builder
  • Next by thread: Re: Bypassing Interface Builder
  • Index(es):
    • Date
    • Thread