Re: Dynamically update drawRect
Re: Dynamically update drawRect
- Subject: Re: Dynamically update drawRect
- From: Quincey Morris <email@hidden>
- Date: Sun, 27 Dec 2009 04:10:59 -0800
On Dec 27, 2009, at 01:18, proger proger wrote:
> I'm still don't know how to do it. As solution i see programmically create MyView class and call drawRect function as i needed. Because now MyView(NSView) is created by nib. And i can't call MyView class instance methods. How to programmically add Custom View and set MyView class ?
I think the piece of information you're missing is that, in Interface Builder, when you drag a custom view "object" into a window, you can then set the *class* of the custom view to any NSView subclass that's defined in your project (such as "MyView", if that's what you've called it).
Then, since your custom view is in a nib, you'll need a way of referring to it. Normally, you'd add an outlet to the nib's File's Owner object, and connect that to your view.
That gives you what you need: a custom view created automatically when the nib is loaded, plus a reference to the custom view that you can use for sending messages to.
Further references:
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaViewsGuide/SubclassingNSView/SubclassingNSView.html#//apple_ref/doc/uid/TP40002978-CH7-SW4
http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/IB_UserGuide/EditingNibFileObjects/EditingNibFileObjects.html#//apple_ref/doc/uid/TP40005344-CH12-SW31
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html#//apple_ref/doc/uid/10000051i-CH4-SW19
_______________________________________________
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