我正在尝试使用Swift 3将项目从iOS 8迁移到Xcode 8中的iOS 8到iOS10.我遇到了一个错误,在我的扩展程序中我声明了一些文件私有函数,而这些函数中的方法是由于私有保护级别而无法访问.
I'm trying to migrate my project from iOS 8 to iOS 10 in Xcode 8 using Swift 3. I've encountered an error where in my extension I've declared some file private functions, and the methods within those functions are inaccessible due to private protection level.
这是我得到错误的地方:
Here is where I get the error:
extension VideoViewerViewController: SeekerViewDelegate { fileprivate func seekerViewBeginSeeking(view: SeekerView) { self.shouldStartPlayingAfterSeek = self.player.rate > 0.0 //'shouldStartPlayingAfterSeek' is inaccessible due to 'private' protection level self.pause() //'pause()' is inaccessible due to 'private' protection level }这是我的班级所遵循的协议:
This is the protocol that my class is conforming to:
private protocol SeekerViewDelegate: class { func seekerViewBeginSeeking(view: SeekerView) func seekerView(view: SeekerView, didSeek progress: CGFloat) func seekerViewDidEndSeeking(view: SeekerView) }我仍在努力掌握文件私有,私有和内部文件的概念.
I'm still struggling to grasp the concept of fileprivate, private, and internal.
感谢所有帮助,谢谢
推荐答案internal对当前模块是私有的. fileprivate是当前文件(以前称为private)的专用文件.新的private在当前范围内是私有的(更接近于大多数人可能认为私有的范围).
internal is private to the current module. fileprivate is private to the current file (which used to be called private). The new private is private to the current scope (closer to what most people probably think of as private).
更多推荐
由于“私有"保护级别,无法访问func
发布评论