Skip to content

Instantly share code, notes, and snippets.

@AliSoftware
AliSoftware / Demo.swift
Last active October 31, 2023 12:25
NestableCodingKey: Nice way to define nested coding keys for properties
struct Contact: Decodable, CustomStringConvertible {
var id: String
@NestedKey
var firstname: String
@NestedKey
var lastname: String
@NestedKey
var address: String
enum CodingKeys: String, NestableCodingKey {
@SamClewlow
SamClewlow / SCMockURLProtocol.m
Created February 4, 2016 13:23
A basic NSURLProtocol subclass useful for capturing and mocking JSON responses
#import "SCMockURLProtocol.h"
#define HARVEST_MODE NO
#define MOCK_MODE YES
@interface SCMockURLProtocol()<NSURLConnectionDelegate>
@property (nonatomic, strong) NSURLRequest *currentRequest;
@property (nonatomic, strong) NSURLSessionTask *currentTask;
@property (nonatomic, strong) NSURLConnection *connection;