0
我使用的UIBlockButton
代碼this post:如何用ARC製作UIBlockButton套裝?
typedef void (^ActionBlock)();
@interface UIBlockButton : UIButton {
ActionBlock _actionBlock;
}
-(void) handleControlEvent:(UIControlEvents)event
withBlock:(ActionBlock) action;
@implementation UIBlockButton
-(void) handleControlEvent:(UIControlEvents)event
withBlock:(ActionBlock) action
{
_actionBlock = Block_copy(action);
[self addTarget:self action:@selector(callActionBlock:) forControlEvents:event];
}
-(void) callActionBlock:(id)sender{
_actionBlock();
}
-(void) dealloc{
Block_release(_actionBlock);
[super dealloc];
}
@end
,但我改變了我的代碼,ARC下,如何更改代碼,以確保一切正常?
感謝您編輯我的帖子,並很快重放我的問題。 – jeswang 2012-07-12 10:02:05
'[self setActionBlock:action];'可以寫成'self.actionBlock = action;' – newacct 2012-07-12 22:14:43