Read-only and non-computed variable properties in Swift

Simply prefix the property declaration with private(set), like so:

public private(set) var hours:   UInt = 0
public private(set) var minutes: UInt = 0
public private(set) var seconds: UInt = 0

private keeps it local to a source file, while internal keeps it local to the module/project.

private(set) creates a read-only property, while private sets both, set and get to private.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)