Questions tagged «fast-enumeration»

1
enumerateObjectsUsingBlock的BOOL * stop参数是什么?
enumerateObjectsUsingBlock:最近,我为满足快速枚举的需求一直在使用很多东西,而且我很难理解BOOL *stop枚举块中的用法。 在NSArray类引用状态 stop:对布尔值的引用。该块可以将值设置为,YES以停止对该数组的进一步处理。该stop参数是唯一的参数。您只能将此Boolean设置YES为Block内。 因此,当然可以在块中添加以下内容以停止枚举: if (idx == [myArray indexOfObject:[myArray lastObject]]) { *stop = YES; } 据我所知,不明确设置*stop为YES不会产生任何负面影响。枚举似乎会自动在数组末尾停止。那么,使用代码*stop块真的有必要吗?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.