I have one UIViewController
and UIView
(As Component). Below is code for the component.
class ProcessingProgressIndicator: UIView {
var progressView: UIProgressView!
func changeProgress(_ progress: Float) {
progressView.progress = progress
}
}
So I use this component in multiple controllers. So when I need to change the value of progress I have used as below in my controller.
myProgressView.changeProgress(progress)
So to make the component Protocol Oriented I added below to code.
protocol ProgressUpdateable {
func updateWith(progressView: ProcessingProgressIndicator,progress: Float)
}
extension ProgressUpdateable {
func updateWith(progressView: ProcessingProgressIndicator,progress: Float) {
// Method gets called and can change progress
}
}
So from my controller, I call method as below
updateWith(progressView: progressView,progress: progressData.progress)
This is how I made it protocol oriented.
So my question is that: Is it correct way of implementation?
I need to pass the object of progressView can I get rid of it?