Hello I am new to Cocoa programming and I met a problem about NSRectFill.
There is one button in the window, and the following is my AppDelegate.m file:
well you don't have any context, the system has no idea where you want to draw. if you want to draw on a view or an image you have to use a lockFocus / unlockFocus pair.
so if you have a view as an outlet called redView
[redView lockFocus];
[[NSColor redColor] set];
NSRectFill(NSMakeRect( 50,50,10,10));
[redView unlockFocus];
but this is a really poor model, you generally want your objects to draw themselves.
when a views drawRect: method is called you already have focus and don't need the lock unlock pair