Skip to content
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

Swift 5 initializers fix #556

Merged
merged 3 commits into from
Mar 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Example/Example/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="pJi-Pa-uLB">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="pJi-Pa-uLB">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
// TODO: Implement better hash

extension Node: Hashable {
public func hash(into hasher: inout Hasher) {
hasher.combine(Unmanaged.passUnretained(self).toOpaque())
}
}


public func == (lhs: Node, rhs: Node) -> Bool {
return lhs === rhs
Expand Down
4 changes: 3 additions & 1 deletion Source/model/draw/Drawable.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
open class Drawable {
import Foundation

open class Drawable: NSObject {

public let visible: Bool
public let tag: [String]
Expand Down
14 changes: 14 additions & 0 deletions Source/model/scene/Node.swift
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,18 @@ open class Node: Drawable {
return .none
}

// MARK: - Hash

override open var hash: Int {
var hasher = Hasher()
hasher.combine(Unmanaged.passUnretained(self).toOpaque())
return hasher.finalize()
}

override open func isEqual(_ object: Any?) -> Bool {
guard let object = object as? Node else {
return false
}
return Unmanaged.passUnretained(self).toOpaque() == Unmanaged.passUnretained(object).toOpaque()
}
}
2 changes: 1 addition & 1 deletion Source/svg/SVGView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ open class SVGView: MacawView {
self.node = node
}

override public init?(node: Node, coder aDecoder: NSCoder) {
@objc override public init?(node: Node, coder aDecoder: NSCoder) {
super.init(node: node, coder: aDecoder)
}

Expand Down
4 changes: 2 additions & 2 deletions Source/views/MacawView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ open class MacawView: MView, MGestureRecognizerDelegate {
}
#endif

public init?(node: Node, coder aDecoder: NSCoder) {
@objc public init?(node: Node, coder aDecoder: NSCoder) {
super.init(coder: aDecoder)

initializeView()
Expand Down Expand Up @@ -132,7 +132,7 @@ open class MacawView: MView, MGestureRecognizerDelegate {
initializeView()
}

public convenience required init?(coder aDecoder: NSCoder) {
@objc public convenience required init?(coder aDecoder: NSCoder) {
self.init(node: Group(), coder: aDecoder)
}

Expand Down