开发者

How to pass a variable through a selector?

开发者 https://www.devze.com 2022-12-25 00:09 出处:网络
I have a method -(void)myMethod:(MyObject*)obj And I am detaching a new thread [开发者_开发知识库NSThread detachNewThreadSelector:@selector(myMethod) toTarget:self withObject:nil];

I have a method

-(void)myMethod:(MyObject*)obj

And I am detaching a new thread

[开发者_开发知识库NSThread detachNewThreadSelector:@selector(myMethod) toTarget:self withObject:nil];

How can I pass a MyObject* through @selector(myMethod)?


[NSThread detachNewThreadSelector:@selector(myMethod:) toTarget:self withObject:myObjectInstance];

You will definitely want that @selector(myMethod:) instead of @selector(myMethod). They mean different things.

0

精彩评论

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

关注公众号