我正在使用Objective-C库。它有一个协议
@protocol RNFrostedSidebarDelegate <NSObject>
@optional
- (void)sidebar:(RNFrostedSidebar *)sidebar didTapItemAtIndex:(NSUInteger)index;
- (void)sidebar:(RNFrostedSidebar *)sidebar didEnable:(BOOL)itemEnabled itemAtIndex:(NSUInteger)index;
@end
我正在尝试在Swift中实现它。我该怎么写这个func
?
答案 0 :(得分:3)
这将是一个实现协议的Swift类
class MyForstedSidebarDelegate : RNFrostedSidebarDelegate {
func sidebar(sidebar: RNFrostedSidebar, didTapItemAtIndex index: UInt) {
... do stuff ...
}
func sidebar(sidebar: RNFrostedSidebar, didEnable itemEnabled: Bool, itemAtIndex index: UInt) {
... do stuff ...
}
}
答案 1 :(得分:0)
@objc protocol RNFrostedSidebarDelegate {
@optional func sideBarDidTapItem(sidebar: RNFrostedSidebar, index: UInt) -> ()
@optional func sideBarDidEnable(sidebar: RNFrostedSidebar, itemEnabled: Bool, index: UInt) -> ()
}