• 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: finding the view
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: finding the view


  • Subject: Re: finding the view
  • From: Eric Peyton <email@hidden>
  • Date: Wed, 13 Mar 2002 08:52:56 -0600

First, add outlets (instant messages of type IBOutlet <type> * - where <type> is NSView, or NSButton, etc.) to your controller class that you have in the nib.

For example,

In the @interface section of the .h file you should have some things like this

IBOutlet NSView * firstView;
IBOutlet NSView * secondView;
etc.

Load the .h file back into the nib by dropping it on the opened nib window.

Make connections from your views in the nib the controller than and attach them to the outlets. Control-drag from the interface item to the controller in the nib.

Then in your code you reference the views by iVar not by some tag or number.

For example, you would do something like

[myFirstView retain]; // so it doesn't get deallocated
[myFirstView removeFromSuperview]; // remove from the window
[myWindow setContentView:mySecondView]; // replace the first view with the second view

(There is no need to go off and "find" the views. You have labeled them, so access them directly).

It's very easy and I know that those books both actually demonstrate this.

You probably need to go through some of the tutorials (not just read them) to get the feeling of IB.

Eric

On Wednesday, March 13, 2002, at 08:38 AM, Paul Cezanne wrote:

Hello

I'm new to Cocoa, working on my first Cocoa project. I've used PowerPlant almost exclusively and MacApp before that so I'm not new to class libraries.

I'm trying to do something which would be very easy in PowerPlant and I'm unable to find the right idiom in Cocoa.

I have a window with a view in it. I want to programmatically replace that view with another view. I know about setContentView but my question is, how do I FIND the new view so I can pass it to setContentView.

In PowerPlant I would have called FindViewByID (or something like that) and passed it the 32 bit "code" for the view that I setup in Constructor.

Right now I have a nib file with all my views inside of it but I don't know how to find them so I can pass them to setContentView.

I've searched the Learing Cocoa and the Hillegass books to no avail.

Thanks for any advice. I'm sure this is just an idiom issue, I'm still thinking PowerPlant.

Paul
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >finding the view (From: Paul Cezanne <email@hidden>)

  • Prev by Date: Re: finding the view
  • Next by Date: doubts regarding serverside programming
  • Previous by thread: Re: finding the view
  • Next by thread: Re: finding the view
  • Index(es):
    • Date
    • Thread