Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

make optional protocol swift

protocol Greeting {
    func sayHello()
}


extension Greeting {
    func sayHello() {
        print("Hello World")
    }
}


class SimpleGreeting: Greeting { //No need to impliment the function
    
}

class WishesGreeting: Greeting {
    func sayHello() {
        print("Hello World this is new year")
    }
}


//Other way to create option protocol
@objc protocol ObjcGreeting {
  @objc optional func sayHello()
}


class ObjcSimpleGreeting: ObjcGreeting { //No need to impliment the function
    
}

class ObjcWishesGreeting: ObjcGreeting {
    func sayHello() {
        print("Hello World this is new year")
    }
}
Comment

PREVIOUS NEXT
Code Example
Swift :: how to get the path of selected PDF/doc from file manager in ios swift programmatically 
Swift :: ForEach tabs swiftui 
Swift :: swift array map to another array 
Swift :: how to Not bool bindng swiftui 
Swift :: ios UIButton change image 
Swift :: response.result.value alamofire 5 
Swift :: swift split string into array of 2 characters 
Swift :: how to center vertically scrollview swiftui 
Swift :: how to add corner in swiftui 
Swift :: swift guard statement 
Swift :: swift switch 
Swift :: struct vs class in swift 
Swift :: Optional & Default Parameter Swift 
Swift :: swift 5 touchupinsideview 
Swift :: does swift language requires mac os system 
Swift :: set time programmatically swift 
Swift :: Incompatible Swift version - framework was built with 5.5 (swiftlang-1300.0.31.1 clang-1300.0.29.1) and the local version is 5.4.2 (swiftlang-1205.0.28.2 clang-1205.0.19.57) 
Swift :: Swift convenience Initializer 
Swift :: Swift Function overloading with Argument Label 
Swift :: Swift Function With Argument Label 
Swift :: swift weekday date component values 
Swift :: how to stack align label over a card in flutter 
Swift :: convert dictionary to data 
Swift :: redux trong swift 
Swift :: get device height spritekit 
Swift :: .next() enum swift 
Ruby :: ruby string to date 
Ruby :: ruby hash map key value 
Ruby :: ruby each with index 
Ruby :: ruby deep merge 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =