calling selector with two arguments on NSThread issue

后端 未结 4 1848
情深已故
情深已故 2020-12-31 05:27

I\'d like to make a Thread with multiple arguments. Is it possible? I have the function:

-(void) loginWithUser:(NSString *) user password:(NSString *) password {
         


        
4条回答
  •  时光说笑
    2020-12-31 05:51

    You need to pass the extra parameters in an object passed to withObject like so:

    NSDictionary *extraParams = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"user",@"password",nil] andKeys:[NSArray arrayWithObjects:@"valueForUser",@"valueForPassword",nil]]
    
    [NSThread detachNewThreadSelector:@selector(loginWithUser:) toTarget:self withObject:extraParams]; 
    

提交回复
热议问题