- (void) Bk_addeventhandler: (void(^) (IDsender)) Handler forcontrolevents: (uicontrolevents) controlevents{Nsparameterassert (handler); Nsmutabledictionary*events =Objc_getassociatedobject (self, bkcontrolhandlerskey); if(!events) {Events=[Nsmutabledictionary dictionary]; Objc_setassociatedobject (self, Bkcontrolhandlerskey, events, objc_association_retain_nonatomic); } nsnumber*key =@ (controlevents); Nsmutableset*handlers =Events[key]; if(!handlers) {Handlers= [NsmutablesetSet]; Events[key]=handlers; } bkcontrolwrapper*target =[[Bkcontrolwrapper alloc] Initwithhandler:handler forcontrolevents:controlevents]; [Handlers Addobject:target]; [Self addtarget:target Action: @selector (Invoke:) forcontrolevents:controlevents];}
Uicontrol's
-(void) AddTarget: (ID) Target action: (SEL) Action forcontrolevents: (uicontrolevents) controlevents;
method does not perform a retain operation on target
Associates an instance of Uicontrol with a reference nsmutabledictionary used to hold multiple target.
This nsmutabledictionary takes uicontrolevents as key and Nsmutableset as value.
Nsmutableset can add multiple target.
This enables the addition of multiple block events for Uicontrol.
iOS blockskit Source Learning 1-uicontrol