I was recently browsing through the DemoBots example from Apple and I came across:
/// The scene that is currently being presented.
private (set) var currentSceneMetadata: SceneMetadata?
What exactly does (set)
do and what other options (if any) are available here?
It means only setter is private. So currentSceneMetadata access for get is the default--which is internal-- but that of set is private. So it can only be changed from within the same source file.
Link to confirm: https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/AccessControl.html
EDIT: You could even do something like this:
public private (set) var name: String
which means name's access level for setter is private and for getter is public.
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