Skip to content

Instantly share code, notes, and snippets.

View sgoodwin's full-sized avatar

Samuel Goodwin sgoodwin

View GitHub Profile
//
// File.swift
// Swipey
//
// Created by Samuel Goodwin on 07/03/2022.
//
import Foundation
import AVFoundation
import Combine
@sgoodwin
sgoodwin / CustomAsserts.swift
Created February 28, 2020 10:55
How to do "assert no difference" and "assert difference" in Swift
func XCTAssertNoDifference<T>(_ context: NSManagedObjectContext, request: NSFetchRequest<T>, file: StaticString = #file, line: UInt = #line, work: () -> Void) {
let oldCount = try! context.count(for: request)
work()
let newCount = try! context.count(for: request)
XCTAssertEqual(oldCount, newCount, "Count incorrectly changed: \(oldCount) to \(newCount)", file: file, line: line)
}
func XCTAssertDifference<T>(_ context: NSManagedObjectContext, request: NSFetchRequest<T>, difference: Int, file: StaticString = #file, line: UInt = #line, work: () -> Void) {
enum Note: Int {
case C = 0
case Csharp
case D
case Dsharp
case E
case F
case Fsharp
case G
case Gsharp

Keybase proof

I hereby claim:

To claim this, I am signing this object:

class SomeCustomViewController: UIViewController {
override var next: UIResponder? {
get {
return nil
}
set {
return
}
}
}
let predicate = NSPredicate(format: "%@.completedUnitCount == 1", argumentArray: [progress])
let exp = expectation(for: predicate, evaluatedWith: progress)
@sgoodwin
sgoodwin / API_Doc.swift
Last active March 21, 2018 19:08 — forked from projectxcappe/API_Doc.swift
API_Doc.swift
//Login
Login {
let email: String
let fb_id: String //when fb is implemented
let password: String
let password_reset_code: String
let phone_number: String
let user_id: String
}
class ForwardSegue: UIStoryboardSegue {
override func perform() {
let source = self.sourceViewController as! UIViewController
let destination = self.destinationViewController as! UIViewController
let window = UIApplication.sharedApplication().keyWindow!
window.insertSubview(destination.view, aboveSubview: source.view)
destination.animateIn()
source.animateOut {
Alamofire.request(SharingRouter.GroupAdd(sharing: sharing, name: name)).responseJSON(options: nil) { (request, response, json, error) -> Void in
let group = flatMap(map(json, JSONValue.parse), Group.decode)
block(group)
}
@sgoodwin
sgoodwin / Podfile
Created November 15, 2014 11:09
The Podfile for my app, Chainguard
# Uncomment this line to define a global platform for your project
platform :ios, "8.0"
target "Chainguard" do
pod 'iOS7Colors', '~> 2.0.0'
end
target "ChainguardTests" do
pod 'OCMockito'
end