diff --git a/Sources/SDCALayer/Model/Layer/JCAGradientLayer.swift b/Sources/SDCALayer/Model/Layer/JCAGradientLayer.swift index 4d628fb..419ebfa 100644 --- a/Sources/SDCALayer/Model/Layer/JCAGradientLayer.swift +++ b/Sources/SDCALayer/Model/Layer/JCAGradientLayer.swift @@ -72,13 +72,13 @@ public class JCAGradientLayer: JCALayer { var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(colors, forKey: .colors) - try container.encode(locations, forKey: .locations) + try container.encodeIfPresent(colors, forKey: .colors) + try container.encodeIfPresent(locations, forKey: .locations) - try container.encode(startPoint, forKey: .startPoint) - try container.encode(endPoint, forKey: .endPoint) + try container.encodeIfPresent(startPoint, forKey: .startPoint) + try container.encodeIfPresent(endPoint, forKey: .endPoint) - try container.encode(type, forKey: .type) + try container.encodeIfPresent(type, forKey: .type) } public override func applyProperties(to target: CALayer) { diff --git a/Sources/SDCALayer/Model/Layer/JCAScrollLayer.swift b/Sources/SDCALayer/Model/Layer/JCAScrollLayer.swift index d727212..f13a8b6 100644 --- a/Sources/SDCALayer/Model/Layer/JCAScrollLayer.swift +++ b/Sources/SDCALayer/Model/Layer/JCAScrollLayer.swift @@ -46,7 +46,7 @@ public class JCAScrollLayer: JCALayer { var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(scrollMode, forKey: .scrollMode) + try container.encodeIfPresent(scrollMode, forKey: .scrollMode) } public override func applyProperties(to target: CALayer) { diff --git a/Sources/SDCALayer/Model/Layer/JCAShapeLayer.swift b/Sources/SDCALayer/Model/Layer/JCAShapeLayer.swift index 1fb650a..5455186 100644 --- a/Sources/SDCALayer/Model/Layer/JCAShapeLayer.swift +++ b/Sources/SDCALayer/Model/Layer/JCAShapeLayer.swift @@ -111,25 +111,25 @@ public class JCAShapeLayer: JCALayer { var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(path, forKey: .path) - try container.encode(fillColor, forKey: .fillColor) + try container.encodeIfPresent(path, forKey: .path) + try container.encodeIfPresent(fillColor, forKey: .fillColor) - try container.encode(fillRule, forKey: .fillRule) + try container.encodeIfPresent(fillRule, forKey: .fillRule) - try container.encode(strokeColor, forKey: .strokeColor) + try container.encodeIfPresent(strokeColor, forKey: .strokeColor) - try container.encode(strokeStart, forKey: .strokeStart) - try container.encode(strokeEnd, forKey: .strokeEnd) + try container.encodeIfPresent(strokeStart, forKey: .strokeStart) + try container.encodeIfPresent(strokeEnd, forKey: .strokeEnd) - try container.encode(lineWidth, forKey: .lineWidth) - try container.encode(miterLimit, forKey: .miterLimit) + try container.encodeIfPresent(lineWidth, forKey: .lineWidth) + try container.encodeIfPresent(miterLimit, forKey: .miterLimit) - try container.encode(lineCap, forKey: .lineCap) - try container.encode(lineJoin, forKey: .lineJoin) + try container.encodeIfPresent(lineCap, forKey: .lineCap) + try container.encodeIfPresent(lineJoin, forKey: .lineJoin) - try container.encode(lineDashPhase, forKey: .lineDashPhase) + try container.encodeIfPresent(lineDashPhase, forKey: .lineDashPhase) - try container.encode(lineDashPattern, forKey: .lineDashPattern) + try container.encodeIfPresent(lineDashPattern, forKey: .lineDashPattern) } public override func applyProperties(to target: CALayer) { diff --git a/Sources/SDCALayer/Model/Layer/JCATextLayer.swift b/Sources/SDCALayer/Model/Layer/JCATextLayer.swift index 360534b..03db64d 100644 --- a/Sources/SDCALayer/Model/Layer/JCATextLayer.swift +++ b/Sources/SDCALayer/Model/Layer/JCATextLayer.swift @@ -96,20 +96,20 @@ public class JCATextLayer: JCALayer { var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(string, forKey: .string) + try container.encodeIfPresent(string, forKey: .string) - try container.encode(font, forKey: .font) - try container.encode(fontSize, forKey: .fontSize) + try container.encodeIfPresent(font, forKey: .font) + try container.encodeIfPresent(fontSize, forKey: .fontSize) - try container.encode(foregroundColor, forKey: .foregroundColor) + try container.encodeIfPresent(foregroundColor, forKey: .foregroundColor) - try container.encode(isWrapped, forKey: .isWrapped) + try container.encodeIfPresent(isWrapped, forKey: .isWrapped) - try container.encode(truncationMode, forKey: .truncationMode) + try container.encodeIfPresent(truncationMode, forKey: .truncationMode) - try container.encode(alignmentMode, forKey: .alignmentMode) + try container.encodeIfPresent(alignmentMode, forKey: .alignmentMode) - try container.encode(allowsFontSubpixelQuantization, forKey: .allowsFontSubpixelQuantization) + try container.encodeIfPresent(allowsFontSubpixelQuantization, forKey: .allowsFontSubpixelQuantization) } public override func applyProperties(to target: CALayer) {