​Swift is really a strong and intuitive programming language for macOS, iOS, watchOS and tvOS....

Page 116

Swift

var mark: Int var mark2: Int } The syntax for creating instances let studrecord = student()

Example class MarksStruct { var mark: Int init(mark: Int) { self.mark = mark } }

class studentMarks { var mark = 300 } let marks = studentMarks() println("Mark is \(marks.mark)") When we run the above program using playground, we get the following result: Mark is 300

Accessing Class Properties as Reference Types Class properties can be accessed by the '.' syntax. Property name is separated by a '.' after the instance name. class MarksStruct { var mark: Int init(mark: Int) { self.mark = mark } }

class studentMarks { 104


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