Swift 3.0
I know that fileprivate
access level modifier limited using of function/property to source file where it was declared and private
- limited to lexical scope where was declared. But it seems that this rule not apply for extensions. E.G. this code is valid:
class Foo {
}
fileprivate extension Foo {
var aa: Int {
return aaa + 10
}
}
private extension Foo {
var aaa: Int {
return 20
}
}
Can someone help me figured out difference between them? Thanks.
Swift 4.0
private
is now accessible in extension but within same file. If you declare/define extension in other file, then your private variable will not be accessible to your extension.
fileprivate
is accessible within same file.