美文网首页刘的个人专题
减少数组写循环代码的方法makeObjectsPerformSe

减少数组写循环代码的方法makeObjectsPerformSe

作者: 辉546 | 来源:发表于2019-07-09 11:09 被阅读1次

iOS数组makeObjectsPerformSelector:SEL方法使用

一. 数组的makeObjectsPerformSelector:SEL方法来减少自己写循环代码.
 [self.answerView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
 

 1.  makeObjectsPerformSelector:@select(aMethod)

     简介:让数组中的每个元素 都调用 aMethod 

 2.  makeObjectsPerformSelector:@select(aMethod) withObject:oneObject

     简介:让数组中的每个元素 都调用 aMethod  并把 withObject 后边的 oneObject 对象做为参数传给方法aMethod

[array makeObjectsPerformSelector:@selector(setRecurringDelegate:) withObject:self]; /*将检测到的该自动插入的交易插入数据库*/
 
[array makeObjectsPerformSelector:@selector(insertRecursion)];
/*将检测到的该自动插入的交易插入数据库*/

转载自https://www.jianshu.com/p/16c413e2071a

相关文章

网友评论

    本文标题:减少数组写循环代码的方法makeObjectsPerformSe

    本文链接:https://www.haomeiwen.com/subject/mbotkctx.html