In an Objective-C block, can you make the outer method return? a la Ruby proc? -


in ruby, calling return inside block or nested blocks transfer control , return innermost wrapping method, i'm talking proc. in ruby lambda return returns block , calling method continues, , how objective-c blocks work.

is there way ruby's proc semantics w.r.t returning in objective-c? want return inside block return outer method.

i'm not familiar ruby, way objc block exert control on enclosing method method test return value.

this simple as:

- (id)bloviate:(id (^)(void))bombast  {     // method returns results of block call;     // thus, strictly speaking, method returns when     // block does.     return bombast(); } 

or can check return value , conditionally return method:

- (id)elucidate:(bool (^)(id))explanation {     id obj = /* object */;     if( explanation(obj) ) {         return obj;     }     // else continue } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -