​Quick is really a strong and instinctive coding language for macOS, iOS, watchOS and tvOS....

Page 217

Swift

class subClass: mainClass, tcpprotocol { var no2: Int init(no1: Int, no2 : Int) { self.no2 = no2 super.init(no1:no1) } // Requires only one parameter for convenient method required override convenience init(no1: Int)

{

self.init(no1:no1, no2:0) } } let res = mainClass(no1: 20) let print = subClass(no1: 30, no2: 50)

println("res is: \(res.no1)") println("res is: \(print.no1)") println("res is: \(print.no2)") When we run the above program using playground, we get the following result: res is: 20 res is: 30 res is: 50

Protocols as Types Instead of implementing functionalities in a protocol they are used as types for functions, classes, methods etc. Protocols can be accessed as types in: 

Function, method or initialize as a parameter or return type



Constant, variable or property



Arrays, dictionaries or other containers as items

protocol Generator { typealias members 205


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