The sublayers property for CALayer is defined as [AnyObject]! . When you index ...sublayers[l] , you get AnyObject , which undoubtedly does not have the zPosition property set. You need to disable the returned AnyObject before CALayer , e.g.
if let layer = self.view.layer.sublayers[l] as? CALayer { layer.zPosition = CGFloat(1) }
In addition, you do not need to deploy sublayers (before signing), because it is declared using ! and therefore implicitly automatically unpacked.
Finally, the error message you provided seems to have been copied incorrectly, as this is pointless.
source share