【发布时间】:2018-12-13 15:12:26
【问题描述】:
我尝试按照本教程实现 iCarousel:https://medium.com/@arb1nsnmgl/icarousel-walkthrough-swift-3-0-887554155242 但是在尝试实现 @protocol 时,它给了我 4 条错误消息:
- 协议类型中应为“{”
- 需要一个属性名称
- 协议“iCarouselDataSource”不能嵌套在另一个声明中
- 协议不允许泛型参数;改用关联类型
目前代码如下:
import UIKit
class ViewController: UIViewController {
@IBOutlet var carouselView: iCarousel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
//Testing
@protocol iCarouselDataSource <NSObject>
-(NSInteger)numberOfItemsInCarousel:(iCarousel *)carousel;
-(UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSInteger)index reusingView:(nullable UIView *)view;
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
【问题讨论】: