• 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: How many times will a sub-classed NSView be instantiated in a simple Cocoa App?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How many times will a sub-classed NSView be instantiated in a simple Cocoa App?


  • Subject: Re: How many times will a sub-classed NSView be instantiated in a simple Cocoa App?
  • From: Nathan Kinsinger <email@hidden>
  • Date: Sat, 24 May 2008 18:01:44 -0600


On May 24, 2008, at 5:43 PM, Graham Reitz wrote:

(fyi) I am coming from the non Mac C++ land and I am trying to grok Obj-C and the Cocoa framework.

1) Create a simple Cocoa application
2) Open IB and drag a Custom View over to the Window
3) Drag an Object to MainMenu.nib

You don't need to do this, the Custom View is all you need (it is an object).


4) Name the Custom View and Object to the same class name

Just set the class of the Custom View.

5) Write the class files and add them to the project
6) Derive the class from NSView and implement the initWithFrame method.
7) Run the program in debug mode.


initWithFrame is called twice (self equals something different each call).

One is from the Custom View and the other is from the Object.

-Where is the other derived NSView object getting instantiated and what is it?

-Is 'self' the same as 'this'? It doesn't seem like the same since super is the parent class.

-How can I tell if the sub-classed NSView instance is from the Custom View that was dragged over in IB? I did notice that one of the height/width from the NSRect object pass has values the size of the window and the other is 0,0.

The one created from the Object you dragged in doesn't have a view created for it so that is the 0,0.


Any guidance, clarification and etc. will be greatly appreciated.

thanks,
graham

--Nathan _______________________________________________

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: How many times will a sub-classed NSView be instantiated in a simple Cocoa App?
      • From: Graham Reitz <email@hidden>
References: 
 >How many times will a sub-classed NSView be instantiated in a simple Cocoa App? (From: Graham Reitz <email@hidden>)

  • Prev by Date: Re: how to override image cell display in IKImageBroserView?
  • Next by Date: Re: How many times will a sub-classed NSView be instantiated in a simple Cocoa App?
  • Previous by thread: How many times will a sub-classed NSView be instantiated in a simple Cocoa App?
  • Next by thread: Re: How many times will a sub-classed NSView be instantiated in a simple Cocoa App?
  • Index(es):
    • Date
    • Thread