Faisal Syed Faisal Syed - 1 year ago 522
Swift Question

func is inaccessible due to 'private' protection level

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

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download