Swift is just a powerful and user-friendly development language for macOS, iOS, watchOS and tvOS...

Page 125

Swift

enum Enumname { static var storedTypeProperty = " " static var computedTypeProperty: Int { // return an Int value here } }

class Classname { class var computedTypeProperty: Int { // return an Int value here } }

Querying and Setting Properties Just like instance properties Type properties are queried and set with '.' Syntax just on the type alone instead of pointing to the instance. struct StudMarks { static let markCount = 97 static var totalCount = 0 var InternalMarks: Int = 0 { didSet { if InternalMarks > StudMarks.markCount { InternalMarks = StudMarks.markCount } if InternalMarks > StudMarks.totalCount { StudMarks.totalCount = InternalMarks } } } }

var stud1Mark1 = StudMarks() var stud1Mark2 = StudMarks()

stud1Mark1.InternalMarks = 98 113


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.