views:

410

answers:

3

I don't understand this:

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

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

+1  A: 

void * means any kind of pointer data.

rpetrich
+1  A: 

Pass anything you want; void * means it's a buffer without a type, so the system ignores its contents.

Next time a Google search for "void *" might help you figure out what it means—I'm assuming you just didn't understand why it was ignored by the system (it's just for your convenience).

Adam Ernst
+4  A: 

Use it to pass a pointer to the object that you're animating. When you call setAnimationDidStopSelector you have to give it a method selector to call. That method's signature has to be of the form:

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

The context value you defined in beginAnimations is passed untouched to this method. It's just a (void *) which is shorthand for "a pointer to anything you want it to be." An object, an integer, a struct. Whatever.

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

Ramin
Thanks. I think now I get it. I was confused what that could be, since I believed that "void" means "nothing". So I expected something like "ID" there.
Thanks
'void *' just means 'a pointer to something'. i.e. it's a pointer without a defined content type.
Jim Dovey