Question

I have searched everywhere for this one but have had no luck. I am using an NSCollectionView in my project with bindings to Core Data via an Array Controller. In order to make it look the way I want I have subclassed NSView with a new drawRect method and connected this with the view outlet of the NSCollectionViewItem. It all works properly and the bindings are good but it will only perform the custom drawing on the first item in the collection view for some reason. I'm guessing it is to do with the fact that NSCollectionView copies the nibs when creating a new item. Here is my drawRect: method firstly:

@implementation CompanyItemView

-(void)drawRect:(NSRect)dirtyRect
{   
    NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:[self frame]  
                                                         xRadius:6.0f     
                                                         yRadius:6.0f];

    [[NSColor whiteColor] set];
    [path fill];

    [[NSColor darkGrayColor] set];
    [path stroke];
}

@end

Any ideas?

Was it helpful?

Solution

Not completely sure but i Think you need to implement copyWithZone method

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top