-
-
Save cipolleschi/8ee3ccdf5d527dcc79e9a0a001db5dea to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| enum Attachment { | |
| case text(info: Text) | |
| case sticker(info: Stricker) | |
| // common property between text and sticker. | |
| var position: CGPoint { | |
| switch self { | |
| case .text(let info): | |
| return info.position | |
| case .sticker(let info): | |
| return info.position | |
| } | |
| } | |
| } | |
| let aText = Text(content: "Hello World", font: UIFont.systemFont(ofSize: 18), position: .zero) | |
| let aSticker = Stricker(fileURL: URL(string: "http://www.google.com/logo.png")!, position: .init(x: 100, y: 100), scale: 2) | |
| let attachments: [Attachment] = [.text(info: aText), .sticker(info: aSticker)] | |
| // print positions. | |
| for attachment in attachments { | |
| print(attachment.position) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment