to is a label to make code more readable.
Both behave exactly the same.
But,
- from outside perspective (the caller), first form is more understandable: I know view is the view I go to.
- from inside (in the func) perspective, referencing view is more meaningful than using to.
That's why the label is different from the parameter.
Second form is equivalent to
func anchorSizePercent(view view: UIView, sFactor: CGSize) {
Note that the 2 forms are different func (signature is different). So you can have both in code, there will not be a compiler error. So important to know which you call.
func anchorSizePercent(to view: UIView, sFactor: CGSize) {
print("with to label")
}
func anchorSizePercent(view: UIView, sFactor: CGSize) {
print("without label")
}
if you call
myHeader.anchorSizePercent(to: myView, sFactor: CGSize(width: 0.8, height: 0.2))
myHeader.anchorSizePercent(view: myView, sFactor: CGSize(width: 0.8, height: 0.2))
you will get in log:
- with to label
- without label