I have one UIViewControllerand UIView(as a component). Below is the code for the component.
class ProcessingProgressIndicator: UIView {
var progressView: UIProgressView!
func changeProgress(_ progress: Float) {
progressView.progress = progress
}
}
Therefore, I use this component in several controllers. Therefore, when I need to change the value of the progress that I used, as shown below in my controller.
myProgressView.changeProgress(progress)
So, to add the Component Protocol Oriented component below to the 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 the method below
updateWith(progressView: progressView,progress: progressData.progress)
This is how I made it protocol oriented.
So my question is: Is the implementation method correct?
I need to pass a progressView object, can I get rid of it?
source
share