Need help with warning: passing argument 1 of ... from distinct Objective C type

  • I am getting a compiler warning that makes no sense to me:

    warning: passing argument 1 of 'setImage:' from distinct Objective C
    type

    My code is generating a CIImage and then passing it to a view object
    (VideoView) for drawing. As far as I can tell, the compiler is trying
    to tell me that the object (CIImage) that I am sending to the setImage
    method is of the wrong type.  But it looks right to me. Does anyone
    know what is going wrong here?

    CIImage *resultImg;
    CIFilter *sbcAdjust;
    CIImage *ciImage = [CIImage alloc];
    [ciImage initWithBitmapImageRep:bitmap];
    sbcAdjust = [CIFilter filterWithName:@"CIColorControls"];
    [sbcAdjust setDefaults];
    [sbcAdjust setValue:ciImage forKey:@"inputImage"];
    [sbcAdjust setValue:[NSNumber numberWithFloat:brightness]
    forKey:@"inputBrightness"];
    [sbcAdjust setValue:[NSNumber numberWithFloat:contrast]
    forKey:@"inputContrast"];
    resultImg = [sbcAdjust valueForKey: @"outputImage"];
    [videoView setImage:resultImg];

    In the VideoView class, setImage is defined as follows:

    - (void)setImage:(CIImage *)frameImage
    {
    [frameImage retain];
    [image release];
    image = frameImage;
    [self setNeedsDisplay:YES];
    }
  • On Nov 6, 2007, at 11:07 AM, Jason Horn wrote:

    > warning: passing argument 1 of 'setImage:' from distinct Objective C
    > type
    >
    > My code is generating a CIImage and then passing it to a view object
    > (VideoView) for drawing. As far as I can tell, the compiler is
    > trying to tell me that the object (CIImage) that I am sending to the
    > setImage method is of the wrong type.  But it looks right to me.
    > Does anyone know what is going wrong here?

    It's possible the compiler is mismatching your call to -setImage: and
    is thinking you're messaging an NSImageView or something, which takes
    an NSImage. Make sure the code is importing the header of the object
    that has the -setImage: method. If that still doesn't work, then you
    might have to cast the receiver...

    > CIImage *ciImage = [CIImage alloc];
    > [ciImage initWithBitmapImageRep:bitmap];

    Unless you really know what you're doing, you should always call
    +alloc and -init on the same line.

    Nick Zitzmann
    <http://www.chronosnet.com/>
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today