@selector - With Multiple Arguments?

前端 未结 9 748
刺人心
刺人心 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:07

    Elaborating on Ben-Uri's answer, which can be written way shorter.

    E.g. calling the UIView method - (CGPoint)convertPoint:(CGPoint)point toView:(UIView *)view can be done as follows:

    SEL selector = @selector(covertPoint:toView:);
    IMP method = [viewA methodForSelector:selector];
    CGPoint pointInB = method(viewA, selector, pointInA, viewB);
    

提交回复
热议问题