Skip to content

Instantly share code, notes, and snippets.

View SpencerCurtis's full-sized avatar

Spencer Curtis SpencerCurtis

View GitHub Profile
h1 {
font-size: 2em;
}

Spencer Curtis built the Adderr app as a Commercial app. This SERVICE is provided by Spencer Curtis and is intended for use as is.

This page is used to inform visitors regarding my policies with the collection, use, and disclosure of Personal Information if anyone decided to use my Service.

If you choose to use my Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that I collect is used for providing and improving the Service. I will not use or share your information with anyone except as described in this Privacy Policy.

The terms used in this Privacy Policy have the same meanings as in our Terms and Conditions, which is accessible at Adderr unless otherwise defined in this Privacy Policy.

Information Collection and Use

Objective 1 - understand and explain Codable's data types

Codable is actually a combination of the Encodable and Decodable protocols. Encodable turns your model object's values into a different format such as JSON or a Plist, while Decodable does the opposite. Each protocol has just a single method. These methods will get called when you call encode or decode. Before we look at how to implement these methods ourselves, you will need to understand a few data types.

Looking at both Encodable's encode(to encoder: Encoder) throws and Decodable's init(from decoder: Decoder) throws on a surface level, we see that they have an Encoder and a Decoder argument respectively. They are both protocols, which are then adopted by JSONEncoder/Decoder and PropertyListEncoder/Decoder, and any custom encoder and decoder that you may create. Both encoders and decoders have essentially the same properties and methods. We'll look at the Decoder's properties and methods below:

Properties:

  • codingPath: Allow
@SpencerCurtis
SpencerCurtis / ShiftableViewController.swift
Last active May 20, 2020 17:45
A UIViewController subclass that manages shifting the view controller up when editing a UITextField or UITextView that would normally be obscured by they keyboard popping up so that the text input is visible.
//
// ShiftableViewController.swift
//
// Copyright © 2020 Spencer Curtis. All rights reserved.
//
/*
All you need to do is set your subclass of ShiftableViewController as the delegate for all
UITextFields and UITextViews that you want to be shifted up so the keyboard doesn't obscure it.