calling selector with two arguments on NSThread issue

后端 未结 4 1978
情深已故
情深已故 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:39

    Wrap your selected method with an auxiliary wrapping method, "wrappingMethod", that processes an NSArray of inputs to suit your own method before calling your own method within wrappingMethod. Now detach an NSThread that selects your all new wrappingMethod and takes the NSArray instance for withObject.

    Aside: Having a wrapper here can be particularly helpful if your original method takes one or more primitive types as input and you then have to work with NSNumber or NSStrings, say, to satisfy NSThread.

提交回复
热议问题