我目前正在使用 enumerateObjectsUsingBlock 块在子视图下进行枚举,我如何才能确定该块的完成情况?
以下是区块内容
[self.view.subviews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
// The content
}];
谢谢
我目前正在使用 enumerateObjectsUsingBlock 块在子视图下进行枚举,我如何才能确定该块的完成情况?
以下是区块内容
[self.view.subviews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
// The content
}];
谢谢
This enumerateObjectsUsingBlock
is not an asynchronous method. It runs synchronously. So, it won't proceed to the next line until the enumeration is done.
You're probably used to seeing blocks in conjunction with completion handlers for asynchronous requests (e.g. sendAsynchronousRequest
). But in this case, the enumerateObjectsUsingBlock
is just a mechanism to efficiently enumerate through a collection (see Blocks Can Simplify Enumeration in the Programming with Objective-C guide). And it does this synchronously.