Skip to content

Instantly share code, notes, and snippets.

View perlguy99's full-sized avatar

Brent Michalski perlguy99

View GitHub Profile
@perlguy99
perlguy99 / CoreDataRelationshipsAndSwiftUI.md
Created November 20, 2019 18:40
CoreData Relationships and SwiftUI

Core Data Relationships and SwiftUI

For Core Data entities to track candy bars and their contries of origin...

Relationships come in four forms:

  • A one to one relationship means that one object in an entity links to exactly one object in another entity. In our example, this would mean that each type of candy has one country of origin, and each country could make only one type of candy.
  • A one to many relationship means that one object in an entity links to many objects in another entity. In our example, this would mean that one type of candy could have been introduced simultaneously in many countries, but that each country still could only make one type of candy.
  • A many to one relationship means that many objects in an entity link to one object in another entity. In our example, this would mean that each type of candy has one country of origin, and
@perlguy99
perlguy99 / FilteredLists.md
Created November 20, 2019 16:59
Filtered List in SwiftUI

Filtered Lists

FilteredList.swift

import SwiftUI
import CoreData

struct FilteredList<T: NSManagedObject, Content: View>: View {
    var fetchRequest: FetchRequest<T>
@perlguy99
perlguy99 / ReadingList_11-19-2019.md
Last active November 19, 2019 21:56
Xcode Secrets, Config files, and other misc.

Keeping Secrets Secure

NSHipster on Secrets NSHipster

Apple's On-Demand Resources Guide

On-Demand Resources Guide

Xcode Build Configurations

Has information on things like:

  • Customizing App Name and/or Icon for Internal Builds
  • Managing Constante Across Different Environments
@perlguy99
perlguy99 / Bundle-Decodable.swift
Created November 5, 2019 19:44
Decodable Bundle Extension for JSON Data
extension Bundle {
func decode<T: Codable>(_ file: String) -> T {
guard let url = self.url(forResource: file, withExtension: nil) else {
fatalError("Failed to locate \(file) in bundle.")
}
guard let data = try? Data(contentsOf: url) else {
fatalError("Failed to load \(file) from bundle.")
}
@perlguy99
perlguy99 / SwiftUINotes_2.md
Last active November 4, 2019 20:24
SwiftUI Notes Page 2

SwiftUI Notes (Loading a JSON File)

Loading a JSON File

  1. Create a struct that matches your data in the JSON file

  2. Make the struct Codable and Identifiable

struct Astronaut: Codable, Identifiable {
@perlguy99
perlguy99 / swift_show_a_sheet.swift
Created October 31, 2019 19:56
SwiftUI Showing a Sheet
// Have a View that we want to show in the sheet
struct MyView: View {
var body: some View {
Text("This is my view")
}
}
struct ContentView: View {
// Need something to track the state of the sheet
@perlguy99
perlguy99 / swift_struct_to_class.swift
Created October 31, 2019 19:34
SwiftUI use class instead of struct
//
// ContentView.swift
// iExpense
//
// Created by Michalski (US), James B on 10/31/19.
// Copyright © 2019 Perlguy, Inc. All rights reserved.
//
import SwiftUI
@perlguy99
perlguy99 / change_resolution_of_rhel.txt
Last active September 10, 2019 14:47
Change Resolution of RHEL on a Windows Hyper-V
# Use "grubby" to update all current and future kernels passing the video argument
# for the Microsoft Hyper-V Synthetic Video Frame Buffer driver
# Tried 2560x1440 but got an "out of range" error upon reboot.
grubby --update-kernel=ALL --args="video=hyperv_fb:1920x1080"
# A reboot is required to apply the changes:
reboot
@perlguy99
perlguy99 / SwiftLibraries.md
Created May 30, 2019 17:32
Swift Library's to Keep Around

Libraries Worth Keeping Handy

Glide

Game engine for making 2d games on iOS, macOS and tvOS, with practical examples Glide

EasyClosure

Unified communication patterns with easy closure in Swift EasyClosure