Xcode 4.3 Lion 10.7.3 In a Document app I have an NSMatrix. I only need to override drawRect. Rather than using a sub-class, which seems overkill to me, I decided to try a Category instead. So here's what I did (and it seems to work.) But since this is the first time I've tried such a thing I'm asking your thoughts, advice, etc in case I'm on the wrong track.
Here are my code snippets: Using Control drag from the xib to the Document.h I added @property (weak) IBOutlet NSMatrix *matrix; and manually typed in @interface NSMatrix (Draw) -(void)drawRect:(NSRect)dirtyRect; @end In Document.m I added @implementation NSMatrix (Draw) -(void)drawRect:(NSRect)dirtyRect { // some drawing stuff } @end This allows me to add whatever calls to drawRect I wish from within methods in Document.m What do you think of this approach? Is there a more elegant way? TIA and respect…. Peter _______________________________________________ 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