I am going through Apple's AnimatedTableView example.
It contains some code I haven't seen before, and I was wondering how this is working.
The ATColorCell.m file contains this code:
Why not do or something similar?
It contains some code I haven't seen before, and I was wondering how this is working.
The ATColorCell.m file contains this code:
Code:
- (id)copyWithZone:(NSZone *)zone
{
self = [super copyWithZone:zone];
[COLOR="Blue"] self->_color = [_color retain];[/COLOR] //???
return self;
}
- (NSUInteger)hitTestForEvent:(NSEvent *)event inRect:(NSRect)frame ofView:(NSView *)controlView {
NSPoint point = [controlView convertPoint:[event locationInWindow] fromView:nil];
NSRect colorRect = [self colorRectForFrame:frame];
if (NSPointInRect(point, colorRect)) {
// We combine in our own hit test marker
return NSCellHitTrackableArea | ATCellHitTestColorRect;
} else {
NSUInteger result = [super hitTestForEvent:event inRect:[self _titleFrameForInteriorFrame:frame] ofView:controlView];
// We don't want the label to be editable
[COLOR="Blue"]result = result & ~NSCellHitEditableTextArea; [/COLOR]//??? ~ is negate in math
return result;
}
}
Why not do or something similar?
Code:
(id)copyWithZone:(NSZone *)zone
{
id newobject = [super copyWithZone:zone];
[newobject setColor:[self color]];
return newobject;
}