- (void)enumerateObjectsUsingBlock:(void (NS_NOESCAPE ^)(ObjectType? ?obj ,NSUInteger idx,BOOL*stop))blockAPI_AVAILABLE(mac os(10.6),? ios(4.0), watch os(2.0), tv os(9.0));
方法描述:
Executes a given block using each object in the array, starting with the first object and continuing through the array to the last object.
執(zhí)行一個(gè)給定的block,使用數(shù)組中的每個(gè)對(duì)象。以第一個(gè)元素開(kāi)始,繼續(xù)直到最后一個(gè)元素。
If the block parameter is nil this method will raise an exception. Values allocated within the block will be deallocated after the block is executed. Use?retain?to explicitly maintain those values.
如果定義的block為nil,將會(huì)拋出異常。當(dāng)block執(zhí)行完畢后,block中allocation的值將會(huì)釋放。使用retain來(lái)?yè)碛邢胍獡碛械闹怠?/p>
This method executes synchronously.
這個(gè)方法的是同步執(zhí)行的。
參數(shù)描述:
block:
The block to apply to elements in the array.
在數(shù)組中申請(qǐng)?jiān)氐腷lock。
The block takes three arguments:
block擁有三個(gè)參數(shù)。
obj
The element in the array.
數(shù)組中的元素。
idx
The index of the element in the array.
數(shù)組中元素的index。
stop
A reference to a Boolean value. The block can set the value to YES to stop further enumeration of the array. If a block stops further enumeration, that block continues to run until it’s finished. The stop argument is an out-only argument. You should only ever set this Boolean toYES within the block.
是一個(gè)bool值的引用,block可以把這個(gè)值設(shè)置為yes來(lái)阻止接下來(lái)的數(shù)組遍歷。如果block阻止了遍歷,block會(huì)把此次遍歷執(zhí)行完。stop僅僅是一個(gè)跳出參數(shù),你只能設(shè)置它為yes。