I was just setting a property CABasicAnimationfor shadowPath, and I was curious:
shadowAnimation.toValue = (id)newShadowPath.CGPath;
[note: shadowAnimation is an object CABasicAnimation, and newShadowPathan object UIBezierPath]
this works and no error / warning is displayed in Xcode. However, if I write like this:
CGPathRef test = newShadowPath.CGPath;
shadowAnimation.toValue = (id)test;
This will not compile throwing this warning message:
Cast of C pointer type 'CGPathRef' (aka 'const struct CGPath *') to Objective-C pointer type 'id' requires a bridged cast
So I need to enter it like this:
shadowAnimation.toValue = (__bridge id)test;
Now why is this so? Why don't I get the same error in the first example when I use only (id) newShadowPath.CGPath ;? Would it be correct to post there __bridgeregardless of whether Xcode has detected any problems? Or am I missing the difference here?