@selector - With Multiple Arguments?

前端 未结 9 749
刺人心
刺人心 2020-12-13 02:26

I have been using @selector today for the first time and have not been able to work out how to do the following? How would you write the @selector

9条回答
  •  渐次进展
    2020-12-13 03:00

     

     - (id)performSelector:(SEL)aSelector
               withObject:(id)anObject  
               withObject:(id)anotherObject
    

    From the Documentation:

    This method is the same as performSelector: except that you can supply two arguments for aSelector. aSelector should identify a method that can take two arguments of type id. For methods with other argument types and return values, use NSInvocation.

    so in your case you would use:

    [self performSelector:@selector(printText:andMore:)
               withObject:@"Cake"
               withObject:@"More Cake"]
    

提交回复
热议问题