I'm trying to create copies of CAShapeLayer in swift but I'm getting a crash
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CAShapeLayer copyWithZone:]: unrecognized selector sent to instance 0x282e87e60'
which extra steps should I take to allow CALayer .copy() work without crashing the app? Even if I don't cast the result of .copy() it stills fails exactly at that copy() line...
private var drawLines: [CAShapeLayer]
func getCopiedLayers() -> [CAShapeLayer] {
return drawLines.compactMap { layer -> CAShapeLayer? in
return layer.copy() as? CAShapeLayer
}
}
what I'm doing wrong here? Thanks in advance for the answers