Skip to content

Style #603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
traviskirton opened this issue Jan 21, 2016 · 3 comments
Closed

Style #603

traviskirton opened this issue Jan 21, 2016 · 3 comments
Milestone

Comments

@traviskirton
Copy link
Collaborator

Over the last couple weeks we've started copying objects. A concrete example is:

public convenience init(_ shape: C4Shape) {
     self.init()
     let disable = C4ShapeLayer.disableActions
     C4ShapeLayer.disableActions = true
     self.path = shape.path
     shapeLayer.path = path?.CGPath
     self.frame = shape.frame
     self.lineWidth = shape.lineWidth
     self.lineDashPhase = shape.lineDashPhase
     self.lineCap = shape.lineCap
     self.lineJoin = shape.lineJoin
     self.lineDashPattern = shape.lineDashPattern
     self.fillColor = shape.fillColor
     self.strokeColor = shape.strokeColor
     self.strokeStart = shape.strokeStart
     self.strokeEnd = shape.strokeEnd
     self.miterLimit = shape.miterLimit
     updatePath()
     adjustToFitPath()
     C4ShapeLayer.disableActions = disable
 }

There should be a consistent approach for creating copies of objects.

The previous initialization should also copy basic view properties.

@alejandro-isaza
Copy link
Member

I think the convenience init(_ original: Object) is good.

@alejandro-isaza alejandro-isaza removed their assignment Jan 23, 2016
@traviskirton
Copy link
Collaborator Author

  • C4View
  • C4Shape
  • C4Image
  • C4Movie
  • C4AudioPlayer
  • C4Gradient
  • C4Vector

@traviskirton
Copy link
Collaborator Author

@Aleph7 just starting with this...

adding init(_ original: View) to View and init(_ original: Shape) to Shape causes an error:

Initializer 'init' with Objective-C selector 'init:' conflicts with initializer 'init' from superclass 'View' with the same Objective-C selector

Without an init(original) on View we will have to initialize all the View properties from every subclass. This will be a bit sloppy, imo.

Can you think of a possible solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants