Iphone 将CFTypeRef(又名const void*)发送到类型为'的参数;void*';丢弃限定符

Iphone 将CFTypeRef(又名const void*)发送到类型为'的参数;void*';丢弃限定符,iphone,objective-c,ios6,Iphone,Objective C,Ios6,以下代码中出现警告。使用圆弧 if ( aAnim ) { [UIView beginAnimations:nil context:CFBridgingRetain([NSNumber numberWithInt:aOff])]; [UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; [UIView setAnimationDuration:0.5]; [UIView setAnimationDelegat

以下代码中出现警告。使用圆弧

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:)];
}

CfBrigingRetain
返回声明为
const void*
CFTypeRef

[UIView beginAnimations:context:
context
参数是一个
void*
(没有
常数
),因此发出警告

您可以改为使用
\u桥接器
修复该警告:

[UIView beginAnimations:nil context:(__bridge_retained void *)[NSNumber numberWithInt:aOff]];
请注意,您必须在上下文不再存在时释放上下文,从而平衡
保留

用过。例如,这可以通过转移所有权在“停止选择器”中完成
返回到Objective-C对象:

id obj = (__bridge_transfer id)context;

在哪一行?
aOff
的定义是什么?@LoïsDiQual online[UIView beginAnimations:nil context:cfbridgeingretain([NSNumber numberwhithint:aOff])&aOff是int。我可以使用[UIView beginAnimations:nil context:(u bridge void*)[NSNumber numberwhithint:aOff]]@Zubair:没有,因为数字对象(在本例中它将在自动释放池中)可以在动画完成之前释放。