Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Figured out how to do hash and isEqual in NSObject subclasses in Swift (turns out: Exactly like in Objective-C).
- Loading branch information
Showing
6 changed files
with
40 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// GLLItemOptionalPartMarker.swift | ||
// GLLara | ||
// | ||
// Created by Torsten Kammer on 18.04.18. | ||
// Copyright © 2018 Torsten Kammer. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
/** | ||
* A simple object that only contains a GLLItem; used for selection to mark that | ||
* the "optional parts" section was selected. | ||
* | ||
* Equality and hash code: Two of these are equal - and have equal hash codes - | ||
* if the underlying items are. | ||
*/ | ||
@objc class GLLItemOptionalPartMarker: NSObject { | ||
@objc init(item: GLLItem) { | ||
self.item = item | ||
} | ||
|
||
@objc let item: GLLItem | ||
|
||
override func isEqual(_ object: Any?) -> Bool { | ||
guard let other = object as? GLLItemOptionalPartMarker else { | ||
return false | ||
} | ||
return self.item == other.item | ||
} | ||
|
||
override var hash: Int { | ||
return item.hash | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters