Skip to content

Instantly share code, notes, and snippets.

@lukaskubanek
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukaskubanek/4e3f7657864103d79e3a to your computer and use it in GitHub Desktop.
Save lukaskubanek/4e3f7657864103d79e3a to your computer and use it in GitHub Desktop.
//
// AppDelegate.swift
// SwiftStructsMemoryLeak
//
// Created by Lukas Kubanek on 03/06/15.
// Copyright (c) 2015 Lukas Kubanek. All rights reserved.
//
import Cocoa
protocol Item {
var value: String { get }
}
struct FooItem<T>: Item {
let value: String
let additionalValue: T
init(value: String, additionalValue: T) {
self.value = value
self.additionalValue = additionalValue
}
}
struct ItemWrapper {
let item: Item
init(item: Item) {
self.item = item
}
}
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var window: NSWindow!
func applicationDidFinishLaunching(aNotification: NSNotification) {
let item = FooItem(value: "protocol value", additionalValue: "foo item value")
let _ = ItemWrapper(item: item)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment