Skip to content

Instantly share code, notes, and snippets.


A Wild Austin Feight feighter09

View GitHub Profile
View KeylessUserDefaultsPerson.swift
// Define Model
struct Person {
let firstName: String
let lastName: String
let age: Int
View KeylessUserDefaults.swift
protocol DefaultConvertible {
var serialized: [String : AnyObject] { get }
init?(dictionary: [String : AnyObject])
class Defaults {
let userDefaults = NSUserDefaults.standardUserDefaults()
func save<T: DefaultConvertible>(toSave: T)
View LOLViewDidLoad.m
- (void)viewDidLoad
[super viewDidLoad];
_multipeerController = [MultipeerController.alloc init];
_multipeerController.delegate = self;
[_multipeerController start];
_graphManager = [GraphManager.alloc init];
_graphManager.delegate = self;
_myPeerID = [MCPeerID.alloc init];
_selectedPeer = -1;
View betterViewDidLoad.swift
override func viewDidLoad()
View NetworkingEvolution_Step6_ViewControllerTests.swift
@testable import NetworkingEvolution
import SwiftyJSON
import XCTest
class ViewControllerTests: XCTestCase {
var viewController: ViewController!
override func setUp()
View NetworkingEvolution_Step6_ViewController.swift
import Alamofire
import SwiftyJSON
import UIKit
class ViewController: UIViewController {
convenience init() { self.init(nibName: "ViewController", bundle: nil) }
@IBOutlet weak var label: UILabel!
var fetchUser = FetchUser()
View NetworkingEvolution_Step6_FetchUser.swift
import Alamofire
class FetchUser: NetworkRequest {
typealias ResponseType = User
var endpoint: String { return "post" }
var method: Alamofire.Method { return .POST }
var params: [String : AnyObject] { return ["param": username] }
private var username = ""
View NetworkingEvolution_Step6_FetchUser_ShouldWork.swift
import Alamofire
protocol FetchUserType: NetworkRequest {
associatedtype ResponseType = User
func perform(username: String, callback: (User?, ErrorType?) -> Void)
final class FetchUser: FetchUserType {
typealias ResponseType = User
View NetworkingEvolution_Step6_NetworkClient.swift
import Alamofire
import SwiftyJSON
protocol NetworkClientType {
func makeRequest<Request: NetworkRequest>(networkRequest: Request, callback: (NSData?, ErrorType?) -> Void)
struct NetworkClient: NetworkClientType {
func makeRequest<Request: NetworkRequest>(networkRequest: Request, callback: (NSData?, ErrorType?) -> Void)
View NetworkingEvolution_Step6_NetworkRequest.swift
import Alamofire
import SwiftyJSON
protocol NetworkRequest {
associatedtype ResponseType
// Required
var endpoint: String { get }
var responseHandler: NSData -> ResponseType? { get }
You can’t perform that action at this time.