Reputation: 7721
I am using the KVO validations in my cocoa app. I have a method
- (BOOL)validateName:(id *)ioValue error:(NSError **)outError
My controls can now have their bindings validate. How do I invoke that method with a id *
NOT id
To use the value that is passed in (a pointer to a string pointer) I call this:
NSString * newName = (NSString *)*ioValue;
if ([newName length] < 4) {
otherwise i get bad exec crashes...
passing in with type casting doesnt work: (id *)myStringVar
passing in with a regular id doesnt work either : (id) myStringVar
Upvotes: 1
Views: 755
Reputation: 299355
NSError *error;
[self validateName:&myStringVar error:&error];
The ampersand means "address of." In this case, it is the address of the pointer, or in other words, a pointer to a pointer (which is what an id*
is).
Upvotes: 5