Re: Why does this leak memory?
Re: Why does this leak memory?
- Subject: Re: Why does this leak memory?
- From: Matt Ball <email@hidden>
- Date: Mon, 11 Jul 2005 11:55:56 -0400
With that code, the effect is still the same. When I double click to
edit, the cell's background becomes white, and the text is
highlighted, but I can't edit it or change the highlighted selection.
Also, are you sure that I need to set the new cell's image
immediately? My tableView's willDisplayCell: method deals with setting
images. Each row has a different image.
- Matt Ball
On 7/11/05, glenn andreas <email@hidden> wrote:
>
> On Jul 11, 2005, at 10:40 AM, Matt Ball wrote:
>
> > Interface:
> >
> > #import <Cocoa/Cocoa.h>
> >
> > @interface LayerCell : NSTextFieldCell
> > {
> > NSImage *image;
> > }
> >
> > - (NSImage *)image;
> >
> > @end
> >
> > Implementation of NSCopying:
> >
> > - (id)copyWithZone:(NSZone *)zone
> > {
> > NSCell *copy = [[[self class] alloc] init];
> >
> > return copy;
> > }
>
>
> This does not implement copy correctly - the results are a new object
> that doesn't have an image, so it's not a copy of the original.
>
> You'll need to do something more like:
>
> - (id)copyWithZone:(NSZone *)zone
> {
> LayerCell *copy = [[[self class] alloc] init];
> [copy setImage: [self image]];
> return copy;
> }
>
> Copy is suppose to have all the same value/properties/behavior that
> the original has, and so without this, all the later code that does
> things like:
>
> NSDivideRect (aRect, &imageFrame, &textFrame, 10 + [[self image]
> size].width, NSMinXEdge
>
> is going to fail because there is no image for that copy (returning
> undefined values for -(NSSize) size).
>
>
>
>
> Glenn Andreas email@hidden
> <http://www.gandreas.com/> wicked fun!
> Widgetarium | the quickest path to widgets
>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden