【发布时间】:2016-01-24 11:19:42
【问题描述】:
我有一个 Swift 项目,我在其中使用了一个 Objective C 自定义手势识别器。
到目前为止,我已经成功地转换了一切。不太清楚如何转换 return ^(UITableView *tableView, NSIndexPath *indexPath) { }; 我试过的一切都没有编译。
目标 C 代码:
typedef void(^DRCellSlideActionBlock)(UITableView *tableView, NSIndexPath *indexPath);
typedef void(^DRCellSlideActionStateBlock)(DRCellSlideAction *action, BOOL active);
-(void)doSomething{
squareAction.didTriggerBlock = [self pushTriggerBlock];
}
- (DRCellSlideActionBlock)pushTriggerBlock {
return ^(UITableView *tableView, NSIndexPath *indexPath) {
NSLog(@"Do Something");
}]];
[self presentViewController:alertController animated:YES completion:nil];
};
}
我尝试过的:
错误:连续语句必须分开......
return (tableView: UITableView, indexPath: NSIndexPath) in {
}
也试过这个作为 (UIView.animateWithDuration) 的完成:
错误:连续语句必须分开......
return () -> (tableView: UITableView, indexPath: NSIndexPath) in {
顺便说一句,我对 Swift 有点陌生,所以请原谅我的代码
【问题讨论】:
标签: ios objective-c swift