(set) keyword in swift

I recently looked at Apple's DemoBots example , and I came across:

/// The scene that is currently being presented.
private (set) var currentSceneMetadata: SceneMetadata?

What exactly does (set)and what other options (if any) are available here?

+4
source share
1 answer

This means that only the setter is closed. Thus, currentSceneMetadata strong> default access for get is internal, but the set parameter is private. Therefore, it can only be changed from the same source file.

Confirmation link: https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/AccessControl.html

: - :

public private (set) var name: String

, setter , getter public.

+5

Source: https://habr.com/ru/post/1619099/


All Articles