Page 201


AnyObject To represent the instance of any class type, 'AnyObject' keyword is used. class Subjects { var physics: String init(physics: String) { self.physics = physics } }

class Chemistry: Subjects { var equations: String init(physics: String, equations: String) { self.equations = equations super.init(physics: physics) } }

class Maths: Subjects { var formulae: String init(physics: String, formulae: String) { self.formulae = formulae super.init(physics: physics) } }

let saprint: [AnyObject] = [Chemistry(physics: "solid physics", equations: "Hertz"), Maths(physics: "Fluid Dynamics", formulae: "Giga Hertz"), Chemistry(physics: "Thermo physics", equations: "Decibels"), Maths(physics: "Astro Physics", formulae: "MegaHertz"), Maths(physics: "Differential Equations", formulae: "Cosine Series")]

let samplechem = Chemistry(physics: "solid physics", equations: "Hertz") println("Instance physics is: \(samplechem.physics)") 189

​Quick is a effective and user-friendly coding language for macOS, iOS, watchOS and tvOS....  


Read more
Read more
Similar to
Popular now
Just for you