ios - Custom variable 'layer' used before being initialized -


i create custom calayer set items corner radius.

func getlayercorner(radius:cgfloat) -> calayer {     let layer:calayer     layer.cornerradius = radius     layer.maskstobounds = true      return layer } 

i'm getting variable 'layer' used before being initialized

i'm still learning swift , not sure how init it.

the error states wrong code. need initialise layer before using:

func getlayercorner(radius:cgfloat) -> calayer {     let layer           = calayer()     layer.cornerradius  = radius     layer.maskstobounds = true     return layer } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -