Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i send Multiple Objects with performSelectorOnMainThread

I have two objects one is NSData and another one is NSString. I want to send this two objects with perfomSelectorOnMainThread. How I can do this?

like image 651
Ben10 Avatar asked Aug 09 '12 11:08

Ben10


1 Answers

If you are using XCode 4.4 and later you can simply do:

[self performSelectorOnMainThread:@selector(myMethod:) withObject:@[objectA,objectB] waitUntilDone:NO];

If you have XCode version older then 4.4 use

[self performSelectorOnMainThread:@selector(myMethod:) withObject:[NSArray arrayWithObjects:objectA, objectB, nil] waitUntilDone:NO];

This is your selector methods:

-(void)myMethod:(NSArray*)array{

   ObjectA *objA = [array objectAtIndex:0];
   ObjectB *objB = [array objectAtIndex:1];

}
like image 100
Cyprian Avatar answered Sep 28 '22 15:09

Cyprian