以下代码中会发出警告。使用ARC。
if ( aAnim ) {
[UIView beginAnimations:nil context:CFBridgingRetain([NSNumber numberWithInt:aOff])];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(postSpin:finished:toCCWCellOffset:)];
}
CFBridgingRetain
返回一个CFTypeRef
被声明为const void *
.
The context
的参数[UIView beginAnimations:context:]
is a void *
(没有
这const
),因此发出警告。
您可以使用以下方法修复该警告__bridge_retained
反而:
[UIView beginAnimations:nil context:(__bridge_retained void *)[NSNumber numberWithInt:aOff]];
请注意,您必须平衡这一点retain
当上下文不再存在时释放它
用过的。例如,这可以通过转移所有权在“停止选择器”中完成
回到 Objective-C 对象:
id obj = (__bridge_transfer id)context;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)