开发者

How to pass the object with performSelector:withObject:withObject:

开发者 https://www.devze.com 2023-02-07 19:01 出处:网络
I have a check where I see if the delegate responds to a callback, then I try to performSelector:withObject:withObject:

I have a check where I see if the delegate responds to a callback, then I try to performSelector:withObject:withObject:

if([delegate respondsToSelector:self.callback])
{
    [delegate performSelector:callback withObject:object withObject:error];
}

When this is executed, I end up in the callback me开发者_Python百科thod of

-(void)thisIsMyCallBack {
    //NSLog(@"object = ", object);
}

But I do not have access to the object.

I tried to create another method

-(void)thisIsMyCallBack:(NSObject *)object withObject:(NSObject *)error {
    //NSLog(@"object = ", object);
}

but this is not called, and the callback goes to the first one.

How do I access the objects that I want to pass?


It looks like you need to set your callback property to:

@selector(thisIsMyCallBack:withObject:)

In Obj-C, the the bits that look like named parameters to a method are really part of the method's selector. thisIsMyCallBack:withObject: is not the same as thisIsMyCallBack.

0

精彩评论

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