Re: How many times will a sub-classed NSView be instantiated in a simple Cocoa App?
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