I feel like this should be relatively simple but I can't find a way to accomplish it.
Let say I have
class Parent {
public var file: PFFile?
}
and a subclass
class Child : Parent {
// some functionality that hides access to super.file
}
Problem is I can't mess with the Parent class, but I don't want anyone using the Child class to have access to 'file'. How can I accomplish this in Swift?
Perhaps this one fix it:
class Parent {
public var file: PFFile?
}
class RestrictedParent : Parent {
private override var file: PFFile?
}
class Child : RestrictedParent {
// some functionality that hides access to super.file
}
Here in RestrictedParent
, we can hide any functionality that should not be visible to any of the child class inheriting to it.
EDIT:
A part from doc:
class Car: Vehicle {
var gear = 1
override var description: String {
return super.description + " in gear \(gear)"
}
}
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