Re: drawRect using a Category

2012-04-02 Thread Peter Teeson
Thank you all for your patience and kindness in educating me. I appreciate it very much. I will sub-class which is what I have previously done. This was, for me, a bit of an experiment (which failed). But that's also a good result. Thanks again. Peter On 2012-04-02, at 12:44 AM, Jens Alfke wrot

Re: drawRect using a Category

2012-04-01 Thread Jens Alfke
On Mar 31, 2012, at 6:46 PM, Peter Teeson wrote: > In my app there is only the one NSMatrix instance There's no way to tell, really. For all I know, the Open or Save panels might use NSMatrix. Or the Find panel or the font panel. Heck, I believe in the old days of OpenStep, menus were impleme

Re: drawRect using a Category

2012-04-01 Thread Per Bull Holmen
Den 03:46 1. april 2012 skrev Peter Teeson følgende: > Thanks very much for your input guys. > > David: > I had carefully read the Categories and Extensions page in OBJ-C Programming > Language. > And, based on the first paragraph, assumed I could add functionality to > drawRect for my particula

Re: drawRect using a Category

2012-03-31 Thread Peter Teeson
Thanks very much for your input guys. David: I had carefully read the Categories and Extensions page in OBJ-C Programming Language. And, based on the first paragraph, assumed I could add functionality to drawRect for my particular case. Stephen: In my app there is only the one NSMatrix instan

Re: drawRect using a Category

2012-03-31 Thread David Duncan
On Mar 30, 2012, at 8:31 PM, Peter Teeson wrote: > 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. Categories don't override, they replace. As has already been noted , t

Re: drawRect using a Category

2012-03-30 Thread Jens Alfke
On Mar 30, 2012, at 8:46 PM, Stephen J. Butler wrote: > I wouldn't trust this to be very stable. And I don't see how > subclassing is much more work than this. Agreed. Absolutely do not do this — using categories to change the behavior of existing classes is quite dangerous. Also, why do you n

Re: drawRect using a Category

2012-03-30 Thread Stephen J. Butler
On Fri, Mar 30, 2012 at 10:31 PM, Peter Teeson wrote: > 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.) The problem with this approach is that you've replaced the drawRect: for every NSMatrix instanc

drawRect using a Category

2012-03-30 Thread Peter Teeson
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 a