开发者

My NSBezierPath changes in a NSCFTimer

When I draw this object it one times works but after that my path object (witch is NSBezierPath) changes in a NSCFTimer object.

- (void)draw {
    NSRect drawingbounds = [self drawingbounds];
    if(image == nil) {
        image = [[NSImage alloc] initWithSize:drawingbounds.size];

        [image lockFocus];
        NSAffineTransform *transform = [NSAffineTransform transform];
        [transform translateXBy:-drawingbound开发者_如何学运维s.origin.x yBy:-drawingbounds.origin.y]; 
        [transform concat];
        [[NSColor redColor] set];
        [path stroke];

        [image unlockFocus];
        [image retain];
    }

    [image drawAtPoint:NSMakePoint(10.0, 10.0)
          fromRect: NSMakeRect(0.0, 0.0, 100.0, 100.0)
         operation: NSCompositeSourceOver
          fraction: 1.0];

}

- (NSRect)drawingbounds {
    NSLog([path description]);
    return NSMakeRect(10.0, 10.0, 100.0, 100.0);
    return NSInsetRect([path bounds], -[path lineWidth] , -[path lineWidth]);
}


Please post the code where the path variable is created.

It sounds like the path object is being deallocated, which is why you're seeing another object (NSCFTimer) in its memory location. This will happen if you have not retained the path object correctly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜