Is the foobar:finished:context: method of UIView animations delegate really giving a BOOL for finished?
Althoug I read everywhere that the method signature has a BOOL for finished, I do never get a false. It is always true. And now the strange thing:
When I NSLog that out with %d, it is always either 32 or 40. Other BOOLs I have are either 1 or 0. That makes no sense. So: N开发者_StackOverflow中文版ot a bool, right?
What's that instead, really?
The method signature for the did stop delegate selector is
- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context;
The finished
parameter is an NSNumber
that wraps up a boolean value. In Objective-C and other languages, any non-zero value is considered true (even negative numbers).
You can call [finished boolValue]
on the NSNumber instance to get a true BOOL
, YES
or NO
value.
The finished
boolean value will be NO
if the animation was cancelled or otherwise interrupted before completing it's full animation. If the animation ran through fully, then it will be YES
.
From the docs:
finished
An
NSNumber
object containing a Boolean value. The value isYES
if the animation ran to completion before it stopped orNO
if it did not.
精彩评论