I would like to create a protocol that has different activities. my reference is an interface on Java Android that we can able create a variable as an interface then we initialize like we implement in class. so, what the equivalent of the interface on swift code?
//Android Interface
private OnValueChanged joinDay, birthDay;
//initialize
joinDay = new OnValueChanged(value -> {
//somecode
});
birthday = new OnValueChanged(value -> {
//somecode
});
interface OnValueChanged{
void didChanged(Date value)
}
//END OF ANDROID INTERFACE
//SWIFT PROTOCOL
class myClass : OnValueChanged{
func didChanged(Int value){
//somecode
}
}
protocol OnValueChanged{
func didChanged(Int value)
}
//END OF SWIFT PROTOCOL
What I want is to create a variable or something like that, which could implement different codes for the same Class like on Android Side.
how to do that in swift?
thanks