Im following a tutorial and I’m not sure how to convert this code to get it to run free without errors with ARC enabled.
- (void)setHourHandImage:(CGImageRef)image
{
if (image == NULL) {
hourHand.backgroundColor = [UIColor blackColor].CGColor;
hourHand.cornerRadius = 3;
}else{
hourHand.backgroundColor = [UIColor clearColor].CGColor;
hourHand.cornerRadius = 0.0;
}
hourHand.contents = (id)image;
The only part that is giving me an error is the (id)image;
Also
w = CGImageGetWidth((CGImageRef)hourHand.contents);
(CGImageRef)minHand.contents); gives me an error
Thanks
You need a
__bridgecast.and
The
__bridgecast tells ARC that this cast doesn’t affect the ownership of the object in any way. The alternatives are__bridge_retainedand__bridge_transfer, which are generally used via theCFBridgingRetain()andCFBridgingRelease()functions.