oops with swift
class Maths {//1 //2 let a: Int! let b: Int! private var result: Int? //3 init(a: Int,b: Int) { self.a = a self.b = b } //4 func add() { result = a + b } //5 func displayResult() { print("Result - \(result)") }}let calculation = Maths(a: 2, b: 3)calculation.add()calculation.displayResult()
Also in Swift:
- receive notificationcenter data in swift
- swift bring something to front of view
- dark mode change immediately swift
- swift save data to file
- horizontal slide segue swift
- xcode disable a button
- swift get device screen size
- map swift
- disable trailing swipe action swift
- type String and int swift addition
- swift check dictionary has key
- run a function only once swift
- how to change background color swift
- swift pass function as parameter
- remove last character from string swift
- create dictionary swift
- replace character in swift
- swift allow gesture recognizer over others
- how to loop swift
- save file with % swift
- pop the view controller xcode
- swift enum
- context.fetch() in swift
- uilabel font size swift