On Dec 27, 2009, at 04:22, proger proger wrote:

> I wrote such code for make NSRect and change color:
> 
>  (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
>     // Insert code here to initialize your application 
>     NSRect frame = NSMakeRect(10, 10, 100, 100) ; 
>     [[NSColor blueColor] set];
>     [NSBezierPath fillRect:frame];
>     [customView setNeedsDisplayInRect:frame];
> }

Your drawing code is in the wrong place. 'applicationDidFinishLaunching:' is a 
method of the application delegate object, so it should *not* be drawing 
anything. Also, *this* 'setNeedsDisplayInRect:' call isn't needed, because your 
window is certainly going to draw itself when it's first displayed.

The drawing code should be in your custom view, something like this:

@implementation MyView

...

- (void) drawRect: (NSRect) partOfViewNeedingToBeDrawn
{
        [[NSColor blueColor] set];
        [NSBezierPath fillRect: partOfViewNeedingToBeDrawn];
}

...

You *really* should study the documentation some more. This is all explained 
there, and without a good idea of the way things work in Cocoa, you're going to 
have a hard time with it.


_______________________________________________

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