Search code examples
iphoneobjective-cioscore-animationcore-graphics

CGAfflineTransform UIView and CoreGraphics conflict


I'm using both UIView and CoreGraphics animations in my app but when I compile, the following line gives me errors:

CGAffineTransform *baseDockTransform = (CGAfflineTransform *)[[[%c(SBIconController) sharedInstance] dock] transform];

Here is the error log:

Tweak.xm:156: warning: multiple methods named ‘-transform’ found /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIView.h:156: warning: using ‘-(CGAffineTransform)transform’ /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/CALayer.h:153: warning: also found ‘-(CATransform3D)transform’ Tweak.xm:156: error: no matching function for call to ‘UIView::UIView(CGAffineTransform)’

The compiler doesn't know which method to use. How can I fix this?

Thanks


Solution

  • Make sure you're casting everything properly. [object dock] may return an object from which you can call transform, but unless you cast it properly the compiler will complain.

    Try:

    Instance *sbInstance = [%c(SBIconController) sharedInstance];
    UIView *transformedView = [sbInstance dock]; // assuming that dock returns an instance of UIView
    CGAffineTransform backDockTransform = transformView.transform;
    

    There won't be much overhead in doing things this way and it's easier to read what's going on.