How does an NSView subclass communicate with the controller?

前端 未结 3 1583
野的像风
野的像风 2021-02-06 04:11

I am brand spanking new to Cocoa programming, and am still kind of confused about how things wire together.

I need a pretty simple application that will fire off a singl

3条回答
  •  余生分开走
    2021-02-06 04:44

    you can also use a selector calling method, define two properties in custom class:

    @property id parent;
    @property SEL selector;
    

    set them in view controller:

    graph.selector=@selector(onCalcRate:);
    graph.parent=self;
    

    and call as:

    -(void)mouseDown:(NSEvent *)theEvent {
        [super mouseDown:theEvent];
        [_parent performSelector:_selector withObject:self];
    }
    

提交回复
热议问题