Reputation: 515
This is an image from Apple's documentation example, Why do the first 2 properties have the 'static' keyword?? I thought static should be only used for structures and enums?
Secondly, why does this class have a stored type property? I thought classes could only have computed type properties???
Upvotes: 2
Views: 388
Reputation: 22939
From the Xcode 6.3 (Swift 1.2) release notes, under Swift Language Enhancements:
static
methods and properties are now allowed in classes (as an alias forclass final
).You are now allowed to declare static stored properties in classes, which have global storage and are lazily initialized on first access (like global variables).
Upvotes: 2
Reputation: 437392
Effective Swift 1.2, static
properties are now permitted in classes.
Classes have always been permitted to have stored properties.
Upvotes: 2