Swift Tutorial - Tutorialspoint
println("Student name is specified") } let blankname = studrecord(stname: "") if blankname == nil { println("Student name is lef ...
println("With In Block Two") } let badresult = functions(funct: "five") if badresult == nil { println("Block Does Not Exist") } ...
Subclass initializer cannot delegate up to the superclass initializer when overriding a failable superclass initializer with a n ...
Planet name is: Mercury No Planets like that: [No Planets] The init! Failable Initializer Swift provides 'init?' to define an op ...
var a = 10 println(a) } } class classB: classA { required init() { var b = 30 println(b) } } let res = classA() let print = clas ...
Before a class instance needs to be deallocated 'deinitializer' has to be called to deallocate the memory space. The keyword 'de ...
class baseclass { init() { counter++; } deinit { counter--; } } var print: baseclass? = baseclass() println(counter) println(cou ...
Memory management functions and its usage are handled in Swift language through Automatic reference counting (ARC). ARC is used ...
let mark = 98 println(stname) println(mark) When we run the above program using playground, we get the following result: swift 9 ...
} } var shiba: studmarks? var mari: student? shiba = studmarks(name: "Swift") mari = student(name: "ARC") shiba!.stud = mari mar ...
init(number: Int) { self.number = number } weak var topic: module? deinit { println("Sub Module with its topic number is \(numbe ...
unowned let stname: student init(marks: Int, stname: student) { self.marks = marks self.stname = stname } deinit { println("Mark ...
init(samplename: String, text: String? = nil) { self.samplename = samplename self.text = text } deinit { println("\(samplename) ...
init(module: String, text: String? = nil) { self.module = module self.text = text } deinit { println("\(module) the deinit()") } ...
The process of querying, calling properties, subscripts and methods on an optional that may be 'nil' is defined as optional chai ...
When we run the above program using playground, we get the following result: fatal error: unexpectedly found nil while unwrappin ...
Program for Optional Chaining with '?' class ElectionPoll { var candidate: Pollbooth? } class Pollbooth { var name = "MP" } let ...
return area.count } subscript(i: Int) - > radius { get { return area[i] } set { area[i] = newValue } } func circleprint() { p ...
} } let rectname = rectangle() if let rectarea = rectname.print?.cprint { println("Area of rectangle is \(rectarea)") } else { p ...
var rectarea: circumference? } class radius { let radiusname: String init(radiusname: String) { self.radiusname = radiusname } } ...
«
4
5
6
7
8
9
10
11
12
13
»
Free download pdf