开发者

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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜