Search code examples
iosobjective-cstructcore-animationquartz-graphics

Return a CGAffineTransform from a function


I have a instance method that I'd like to return a CGAffineTransform. I'm currently getting the error

Semantic Issue: Initializing 'CGAffineTransform' (aka 'struct CGAffineTransform') with an expression of incompatible type 'id'

My method name

- (CGAffineTransform)getEllipse

My call to it

CGAffineTransform t = [self getEllipse];

Any help would be great.


Solution

  • Have you made sure that the method is declared somewhere visible to the code that calls it? I.e., if:

    - (CGAffineTransform)getEllipse;
    

    is in MyFoo.h, and MyBar.m contains:

    CGAffineTransform t = [self getEllipse];
    

    then MyBar.m needs to #import "MyFoo.h". Without being able to see the declaration, the calling code will assume that the method returns an object of unknown type, a.k.a. id.