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.
精彩评论