Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

func is inaccessible due to 'private' protection level

Tags:

swift

swift3

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

like image 285
Faisal Syed Avatar asked Sep 27 '16 22:09

Faisal Syed


1 Answers

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

like image 171
Rob Napier Avatar answered Nov 09 '22 04:11

Rob Napier