objective c id *
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
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).
精彩评论