• 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: document based app, custom ibaction
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: document based app, custom ibaction


  • Subject: Re: document based app, custom ibaction
  • From: Jonathan Hess <email@hidden>
  • Date: Tue, 19 Aug 2008 12:59:25 -0700

Hey Bart -

Understanding the "File's Owner" is really an essential part of understanding how to use Interface Builder effectively. At the most basic level, all NIBs are loaded at runtime with a call to -[NSBundle loadNibNamed:owner:]. The method takes two arguments, a NIB name which is the NIB file to load, and an owner, which is the object doing the loading. The "File's Owner", represented by the blue cube in Interface Builder, is a placeholder object that represents the 'owner' that will be passed in at runtime. The File's Owner is a way for you to refer to objects inside of your NIB file from objects outside of your NIB file. When you load the nib at runtime, the blue cube placeholder in Interface Builder is resolved to the owner object you pass into the NIB loading method, and all of the connects you made to the placeholder are made to the owner you passed in instead.

Most NIB files on Mac OS X are loaded for you by various Cocoa classes. NSApplication, NSDocument, NSWindowController, and NSViewController all load nib files for you, and they each pass 'self' in as the parameter to -[NSBundle loadNibNamed:owner:]. This is why your document is represented as the File's Owner for your document NIB.

As an exercise, you might try design your sheet in its own NIB file, and then from your MyDocument class, when it's time to show the sheet, invoke "-[NSBundle loadNibNamed:owner:]", and pass 'self' as the owner. This might help clear up the concept.

After you've mastered the File's Owner, the First Responder is the last difficult concept -
Jon Hess


On Aug 19, 2008, at 6:07 AM, Bart Beulen wrote:

Sorry, didn't know I had to connect the outlets of the mydocument class through file owner.... This basically solved my problems.

Op 19 aug 2008, om 14:03 heeft Graham Cox het volgende geschreven:


On 19 Aug 2008, at 7:03 pm, Bart wrote:

Another similar problem.

I would like to add a sheet to the button I've created. Normally I would create an IBOutlet and connect the window for the sheet to it, combined with a code to open:

[NSApp beginSheet:totalsSheet
	   modalForWindow:[NSApp mainWindow]
		modalDelegate:self
	   didEndSelector:NULL
		  contextInfo:NULL];

and close it:

	[NSApp endSheet:totalsSheet];
	[totalsSheet orderOut:sender];

However, is this possible when using a mydocument class, because I cannot find any outlets in the interface builder....

So, add the outlets you need to the class. It is called *MY*document after all - it's yours ;-)


e.g. in MyDocument.h, add the instance variable:

IBOutlet id	mySheetWindow;

and this will show up in IB for you to connect to.

(This probably isn't the time to get into handling this in a separate controller class, but you may want to revisit this question when you get the hang of it a bit more).

I would also like to create some seperate outlets for displaying some float values from some variables of the mydocument class, this is a similar problems since I don't know where to find the outlets to connect the GUI elements to.

Do you really mean outlet? Or just an instance variable? While an outlet is an instance variable, not all instance variables are outlets...


Still, in either case, just add them to your class definition as above.

At the moment all data is presented in a table using an array controller. This is fine, but I would like to perform some calculations on the same data and present the results in a pop-up window. I guess the method described above should be a nice way to do this.

Well, see how you go. Not sure why a separate pop-up window seems such a good idea, but I guess you're just learning the ropes, so go right ahead.


hth,

Graham
_______________________________________________

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

_______________________________________________

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

_______________________________________________

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


References: 
 >document based app, custom ibaction (From: Bart Beulen <email@hidden>)
 >Re: document based app, custom ibaction (From: "Sherm Pendley" <email@hidden>)
 >Re: document based app, custom ibaction (From: Bart Beulen <email@hidden>)
 >Re: document based app, custom ibaction (From: Bart <email@hidden>)
 >Re: document based app, custom ibaction (From: Graham Cox <email@hidden>)
 >Re: document based app, custom ibaction (From: Bart Beulen <email@hidden>)
 >Re: document based app, custom ibaction (From: Bart <email@hidden>)
 >Re: document based app, custom ibaction (From: Graham Cox <email@hidden>)
 >Re: document based app, custom ibaction (From: Bart Beulen <email@hidden>)

  • Prev by Date: Re: Receiving mouseEnter and mouseExit events.
  • Next by Date: NSTableColumn not usable with binder of class NSTextValueBinder?
  • Previous by thread: Re: document based app, custom ibaction
  • Next by thread: NSString Question
  • Index(es):
    • Date
    • Thread