Vipin Vijay
Vipin Vijay

Reputation: 393

How to pass more than one arguments to a thread?

if I am having a function

-(void)setName:(NSString *)name setAddress:(NSString *)address
{

}

how can I call the above function in

[self performSelector:<#(SEL)#> withObject:<#(id)#> afterDelay:<#(NSTimeInterval)#>];

Upvotes: 0

Views: 145

Answers (3)

Hanon
Hanon

Reputation: 3927

Use NSDictionary as the argument, and you have to define the function to accept the dictionary

[self performSelector:@selector(yourSelector:) withObject:theDictionary afterDelay:<#(NSTimeInterval)#>];

Then you can assign the value by getting the corresponding data in the dictionary

Upvotes: 4

beryllium
beryllium

Reputation: 29767

Try to wrap your objects into another custom object/NSArray/NSDictionary. Something like this:

NSArray *arrayObjects = [NSArray arrayWithObjects:name, address, nil];
[self performSelector:@selector(sel:) withObject:arrayObjects afterDelay:delay];

Upvotes: 2

Parag Bafna
Parag Bafna

Reputation: 22930

you should Use NSArray object. Add your parameter in NSArray object and pass that object.

Upvotes: 2

Related Questions