Just a brief comment on the design of your class.

Why do you declare properties for frame and pane colour, and then have 
additional setter methods that set these properties (and mark the view as 
needing display)?. You can write the property setter methods directly to cause 
a refresh and none of those extra methods are needed. It ensures that there’s 
no way code can change the property without the view redrawing.

The flags for drawing the frame and fill are redundant - you could have the 
colour property set to nil to mean ‘don’t draw this’.

Also, NSColor is immutable so there’s little purpose to having that property 
‘copy’, it can be ‘retain’ (or ‘strong’) and it will save you a small amount of 
space per instance.

These are minor nits to be sure, but often it’s this that makes the difference 
between a good class and a great one.

—Graham




> On 8 Sep 2015, at 3:34 am, Dave <d...@looktowindward.com> wrote:
> 
> @interface LTWDrawFrameView : NSView
> {
> }
> @property (nonatomic,assign)  BOOL                                            
>         pDrawFrameFlag;
> @property (nonatomic,assign)  BOOL                                            
>         pDrawPaneFlag;
> 
> @property (nonatomic,copy)            NSColor*                                
>                         pFrameColor;
> @property (nonatomic,copy)            NSColor*                                
>                         pPaneColor;
> 
> @property (nonatomic,assign)  CGFloat                                         
>         pFrameLineWidth;
> @property (nonatomic,assign)  NSSize                                          
>         pFrameInsetSize;
> 
> -(void) setDrawFrame:(BOOL) theFlag;
> -(void) setDrawPane:(BOOL) theFlag;
> -(void) setFrameColor:(NSColor*) theColor;
> -(void) setPaneColor:(NSColor*) theColor;
> -(void) setFrameLineWidth:(CGFloat) theLineWidth;
> -(void) setFrameInsetSize:(NSSize) theInsetSize;
> 
> @end


_______________________________________________

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

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

Reply via email to