由于“私有"保护级别,无法访问func [英] func is inaccessible due to 'private' protection level

查看:122
本文介绍了由于“私有"保护级别,无法访问func的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆