这个问题在这里Iphone - 如何将参数传递给animationDidStop?在上下文中提出整个问题。根据那里的最佳答案,我在我的 animationDidStopSelector 中发布了上下文。但自从我更新了我的 Xcode,我收到了这个警告
- (void) helloThere: (int) myValue {
// I am trying to pass myValue to animationDidStop
[UIView beginAnimations:nil context:[[NSNumber alloc] initWithFloat:self.view.frame.origin.x]]; //Warning raised on this line
[UIView setAnimationDuration:1.0];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
[UIView setAnimationDelegate:self];
// do stuff
[UIView commitAnimations];
}
- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
CGFloat usesThisValue = [(NSNumber *) context floatValue];
[(NSNumber *) context release];
}
日志中的警告说:
warning: Potential leak of an object [UIView beginAnimations:nil context:[[NSNumber alloc] initWithFloat:self.view.frame.origin.x]]; //Warning raised on this line
1 warning generated.
有解决方案吗?如果没有,我怎样才能为我的项目关闭这个警告?