Objective C calling method dynamically with a string

后端 未结 2 1633
遥遥无期
遥遥无期 2020-12-01 01:50

Im just wondering whether there is a way to call a method where i build the name of the method on the fly with a string.

e.g. I have a method called loaddata

2条回答
  •  眼角桃花
    2020-12-01 02:30

    You can try something like

    SEL s = NSSelectorFromString(selectorName);
    [anObject performSelector:s];
    

提交回复
热议问题