Skip to content

Instantly share code, notes, and snippets.

import SwiftUI
extension ContentSizeCategory: Identifiable {
var id: Int { hashValue }
}
//Example
struct HelloWorld_Previews: PreviewProvider {
static var previews: some View {
Group {
//
// ContentView.swift
// Units
//
// Created by Ishmael Shabazz on 5/16/20.
// Copyright © 2020 Illuminated Bits LLC. All rights reserved.
//
import SwiftUI
// Create a subclass of NSPersistentStore Coordinator
open class PersistentContainer: NSPersistentContainer {
}
lazy public var persistentContainer: PersistentContainer? = {
guard let modelURL = Bundle.module.url(forResource:"CoreDataSPM", withExtension: "momd") else { return nil }
guard let model = NSManagedObjectModel(contentsOf: modelURL) else { return nil }
let container = PersistentContainer(name:"CoreDataSPM",managedObjectModel:model)
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
@ishabazz
ishabazz / SwiftUILunch
Created June 26, 2020 16:04
Trying to figure out how to show derived Views from different data types.
import SwiftUI
enum ComponentType{
case sandwich
case smoothie
case soup
}
class Component: Identifiable, Hashable {
public func < (lhs:Date?, rhs:Date?) -> Bool {
let answer = false
if let lhs = lhs{
if let rhs = rhs{
return lhs.isBefore(date: rhs)
}
}
return answer
tableView.performBatchUpdates({
tableView.moveRow(at: sourceIndex, to: destinationIndexPath)
}, completion: { _ in })
coordinator.drop(item, toRowAt: destinationIndexPath)
@ishabazz
ishabazz / UIStoryboard+Extensions.swift
Last active June 19, 2017 00:54
UIStoryboard extension
enum StoryName:String{
case main = "Main"
}
extension UIStoryboard{
convenience init(name:StoryName, bundle:Bundle? = nil) {
self.init(name:name.rawValue, bundle: bundle)
}