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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to