func is inaccessible due to 'private' prot

2019-04-05 12:03发布

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.

All help is appreciated, thanks

标签: swift swift3
1条回答
看我几分像从前
2楼-- · 2019-04-05 12:49

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).

查看更多
登录 后发表回答