Wednesday 15 September 2010

ios - What is the recommended way to break out of a block or stop the enumeration? -



ios - What is the recommended way to break out of a block or stop the enumeration? -

so, realize break loop or switch.

here's question: there recommended way break out of block? example:

func getcontentfrom(group: alassetsgroup, withassetfilter: alassetsfilter) { group.enumerateassetsusingblock { (result, index , stop) -> void in //i want out when find value because result contains 800++ elements } }

right now, using homecoming not sure if recommended. there other ways? folks.

if want stop current iteration of enumeration, return.

but say:

i want out when find value because result contains 800++ elements

so, means want stop enumeration when find 1 want. in case, set boolean value pointer points to. or, improve name 3rd parameter stop, e.g.:

func getcontentfrom(group: alassetsgroup, withassetfilter: alassetsfilter) { group.enumerateassetsusingblock() { result, index, stop in allow found: bool = ... if found { //i want out when find value because result contains 800++ elements stop.memory = true } } }

ios loops swift break

No comments:

Post a Comment