warning: 'NSOpenGLView' may not respond to

Discussion in 'Mac Programming' started by dbrayford, Jan 28, 2011.

  1. dbrayford macrumors member

    Joined:
    Feb 22, 2010
    #1
    I am getting several compiler warnings in the form of

    Code:
    warning: 'NSOpenGLView' may not respond to '-UpdateGraph'
    but don't know how to fix them.
    The header file is as follows

    Code:
    @interface RegressionView : NSOpenGLView
    {
    	IBOutlet NSTextField *rightcubesize;
    	IBOutlet NSTextField *rightintersections;
    	IBOutlet NSTextField *leftcubesize;
    	IBOutlet NSTextField *leftintersections;
    	IBOutlet NSTextField *selectedcubesize;
    	IBOutlet NSTextField *selectedintersections;
    	IBOutlet NSTextField *regM;
    	IBOutlet NSTextField *regB;
    	
    	
    	CenterPointList *cpl;
    	int *cp;		// center point #
    	int selected;	// index of point for which to display info
    	float xmin, xmax, ymin, ymax;
    	float w, h;			// width and height of window;
    }
    
    - (void) UpdateGraph;
    - (void) setPointerAndScale: (CenterPointList *) cpl0: (int *) cp0: (float *) x0: (float *) x1: (float *) y0: (float *) y1;
    
     
  2. jiminaus, Jan 28, 2011
    Last edited: Jan 28, 2011

    jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #2
    What's the type of the variable at the lines where you get this warning? Is it NSOpenGLView * or RegressionView *?

    [Drinks coffee and then comes back to explain]

    If the variable the type of the variable where these warnings are occurring is NSOpenGLView * then the warning is valid, because only if the object being pointed to is actually a RegressionView instance will it respond to the UpgradeGraph message.

    The easiest way to silence the message would be type cast the variable to RegressionView * before or in the message send. For example:

    Code:
    [(RegressionView *)viewVariable UpdateGraph];
    
    This is assuming you know for sure that viewVariable does point to a RegressionView instance.

    BTW Typical Objective-C style would name the message updateGraph and not UpgradeGraph.
     

Share This Page