ios - executing blocks stored in NSMutableArray with a parameter -
i'm trying understand blocks bit more.
i have these definitions:
@property (nonatomic, retain) nsmutablearray * callbacksonsuccess; @property (nonatomic, copy) void (^callbacksuccesswithuiimage) (uiimage *) ; when image download finishes in completion block , things fine
uiimage *coverimage = [uiimage imagewithdata:data]; callbacksuccesswithuiimage(coverimage); now i'd able same callback blocks stored in callbacksonsuccess nsmutablearray don't know how approach this.
i'm trying in loop, that's not working because of ambigous id class definition:
uiimage *coverimage = [uiimage imagewithdata:data]; (id callbackblock in callbacksonsuccess) {callbackblock(coverimage);} please push me towards right approach.
thank you!
first of all:
consider use typedef blocks, in order ease syntax:
typedef void (^myblock)(uiimage*); //declare somewhere then, can iterate through array this, executing each block inside it:
uiimage *coverimage = [uiimage imagewithdata:data]; (myblock block in callbacksonsuccess) { block(coverimage); } you can use new type in property:
@property (nonatomic, copy) myblock callbacksuccesswithuiimage;
Comments
Post a Comment