简体   繁体   中英

How to pass a variable through a selector?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM