重构此代码以实现ARC合规性

时间:2012-04-02 14:08:21

标签: iphone objective-c ios

我将如何为ARC重构此代码:

- (UIGestureRecognizer *)createTapRecognizerWithSelector:(SEL)selector {
    return [[[UITapGestureRecognizer alloc] initWithTarget:self action:selector] autorelease];
}

感谢您的帮助

2 个答案:

答案 0 :(得分:4)

删除autorelease语句并重命名方法:

- (UIGestureRecognizer *)newTapRecognizerWithSelector:(SEL)selector
{
    return [[UITapGestureRecognizer alloc] initWithTarget:self action:selector];
}

答案 1 :(得分:2)

删除autorelease。应该这样做

希望这会对你有所帮助。