Skip to content

Instantly share code, notes, and snippets.

View ice-cream-coder's full-sized avatar

Alyce Dawson ice-cream-coder

  • Saratoga Springs, UT
View GitHub Profile
@ice-cream-coder
ice-cream-coder / HostingCollectionViewCell.swift
Created February 22, 2021 21:29
A generic class for hosting a SwiftUI.View in a collection view cell.
protocol HasEmptyInitializer {
init()
}
class HostingCollectionViewCell<Content, Model>: UICollectionViewCell where Content: View, Content: HasEmptyInitializer, Model: ObservableObject, Model: HasEmptyInitializer {
private lazy var view: Content = { Content() }()
lazy var model: Model = { Model() }()
lazy var hostingController: some UIViewController = { UIHostingController(rootView: view.environmentObject(model)) }()
@ice-cream-coder
ice-cream-coder / README.md
Last active January 29, 2019 16:47
SCRIPT-8