Skip to content

Instantly share code, notes, and snippets.

Avatar
💜
In love with JS stack.

Jay Mayu mayooresan

💜
In love with JS stack.
View GitHub Profile
View updated-protocol-animal.swift
protocol Animal{
var isIdle : Bool? {get set}
func run()
func stop()
}
View cat.swift
class Cat : Animal, Eye{
var isIdle: Bool? = true
func run() {
print("Cat is running now")
}
func stop() {
print("Cat has stopped now")
}
View final-protocol.swift
protocol Animal{
var isIdle : Bool? {get set}
func run()
func stop()
}
protocol Eye{
func closeEyesAndSleep()
func openEyesAndLookAround()
}
View cat.swift
class Cat : Animal, Eye{
var isIdle: Bool? = true
func run() {
isIdle = true
print("Cat is running now")
}
func stop() {
isIdle = false
View cat.swift
class Cat : Eye{
var isIdle: Bool? = true
func closeEyesAndSleep() {
if isIdle == true{
print("Cat is sleeping now")
}else{
print("Cat will NOT sleep now")
}
}
View EnemyBaseVC.swift
import UIKit
class EnemyBaseVC: UIViewController {
let hasWeaponOfMassDescrtruction : Bool = true
override func viewDidLoad() {
super.viewDidLoad()
}
View EnemyBaseVC.swift
import UIKit
protocol SpyDelegate {
func didFindWeaponOfMassDestruction(found : Bool)
}
class EnemyBaseVC: UIViewController {
let hasWeaponOfMassDescrtruction : Bool = true
View EnemyBaseVC.swift
import UIKit
protocol SpyDelegate {
func didFindWeaponOfMassDestruction(found : Bool)
}
class EnemyBaseVC: UIViewController {
let hasWeaponOfMassDescrtruction : Bool = true
var delegate : SpyDelegate?
View EnemyBaseVC.swift
import UIKit
protocol SpyDelegate {
func didFindWeaponOfMassDestruction(found : Bool)
}
class EnemyBaseVC: UIViewController {
let hasWeaponOfMassDescrtruction : Bool = true
var delegate : SpyDelegate?
View HomeBaseVC.swift
import UIKit
class HomeBaseVC: UIViewController, SpyDelegate {
override func viewDidLoad() {
super.viewDidLoad()
}
func didFindWeaponOfMassDestruction(found: Bool) {
// Handle the received data here