- (id)performSelector:(SEL)aSelector withObject:(id)object1 withObject:(id)object2 这样可以带俩参数
如果我使用[self performSelectorInBackground:@selector(function:withOther:
) withObject:xxx];
XXX该怎么写呢,我试过[NSArray arrayWithObjects:@"a", @"b", nil],直接crash
- (void)function:(NSString *)one withOther:(NSString *)two;
NSString *string1 = @\
"111\"
;
02.
03.
NSString *string2 = @\
"222\"
;
04.
05.
NSMethodSignature *sig = [
self
methodSignatureForSelector:@
selector
(function:withOther:)];
06.
07.
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:sig];
08.
09.
[invocation setTarget:
self
];
10.
11.
[invocation setSelector:@
selector
(function:withOther:)];
12.
13.
[invocation setArgument:&string1 atIndex:2];
14.
15.
[invocation setArgument:&string2 atIndex:3];
16.
17.
[invocation performSelectorInBackground:@
selector
(invoke) withObject:
nil
];