What value can I set in the context parameter for UIView + beginAnimations: context :?

I do not understand this:

+ (void)beginAnimations:(NSString *)animationID context:(void *)context

      

(void *) ----> what data can I provide here?

+1


a source to share


3 answers


Use it to pass a pointer to the object you are animating. When you call setAnimationDidStopSelector

, you must give it a method call to call. This method signature should be of the form:

- (void)animationDidStop:(NSString *)animationID 
                finished:(NSNumber *)finished 
                 context:(void *)context

      



The context value specified in beginAnimations

is not passed to this method. It's just (void *), which is shorthand for "a pointer to whatever you want it to be". Object, integer, struct. Whatever.

Instead of "context", think of it as "userData".

+7


a source


void *

means any kind of pointer data.



+1


a source


Send whatever you want; void *

means it is a typeless buffer, so the system ignores its contents.

Next time Google search for "void *" will help you understand what that means - I assume you just didn't understand why the system was ignored (it's just for your convenience).

+1


a source







All Articles