Since now "Private" can be accessed within an extension what is the significance of "file private". Can anyone explain with an example.
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
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With