In IB I create a NSCollectionView
and its NSCollectionViewItem
and a NSView
which belongs to NSCollectionViewItem
.My NSCollectionItem
consist of a NSImageView
and a NSTextField
.I set them values using cocoa bindings.I want to change the border color of NSImageView
when NSCollectionItem
is selected.I create their own classes for all of them and set their custom class in IB.In NSCollectionViewItem
class I rewrite its setSelected:(BOOL)flag
function.The code is
- (void)setSelected:(BOOL)flag
{
[super setSelected:flag];
[[self view] setSelected:flag];
[[self view] setNeedsDisplay:YES];
}
I want to change the border color when the NSView
calls its draw function.In the NSView
class I create IBOutlets
of the NSImageView
and NSTextField
,connecting them with IB.But when the draw function is called , I use the code
if(selected){
NSLog(@"self.imageView = %@",self.imageView);
}
The result is nil.Why I can't get the imageView of selected NSCollectionViewItem? Where I make the mistake? Help me ,thank you!