Reputation: 753
Since now "Private" can be accessed within an extension what is the significance of "file private". Can anyone explain with an example.
Upvotes: 6
Views: 1332
Reputation: 437702
private
limits access to that class within that file. fileprivate
limits access to that file.
Imagine these are all in the same file:
class Foo {
private var x = 0
fileprivate var y = 0
}
extension Foo {
func bar() {
// can access both x and y
}
}
class Baz {
func qux() {
let foo = Foo()
// can access foo.y, but not foo.x
}
}
Upvotes: 13