As a swift newbie I wonder what the difference between:
var img : UIImageView
var img = UIImageView()
I see them used a lot in the same situation
the first example var img: UIImageView creates a variable the WILL be of type UIImageView, once something is assigned to it. This line itself does not initialize or create a new instance and its not assigned to anything.
the second example is actually creating a new instance of UIImageView assigned to the variable that is called img. It infers from the instance create of UIImageView that it will a variable of type UIImageView so no need to type it, its redundant
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With