This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Define Model | |
struct Person { | |
let firstName: String | |
let lastName: String | |
let age: Int | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol DefaultConvertible { | |
var serialized: [String : AnyObject] { get } | |
init?(dictionary: [String : AnyObject]) | |
} | |
class Defaults { | |
let userDefaults = NSUserDefaults.standardUserDefaults() | |
func save<T: DefaultConvertible>(toSave: T) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func viewDidLoad() | |
{ | |
super.viewDidLoad() | |
initMultipeerDependencies() | |
configureTableView() | |
addSegmentedControl() | |
addDismissKeyboardRecognizer() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@testable import NetworkingEvolution | |
import SwiftyJSON | |
import XCTest | |
class ViewControllerTests: XCTestCase { | |
var viewController: ViewController! | |
override func setUp() | |
{ | |
super.setUp() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Alamofire | |
protocol FetchUserType: NetworkRequest { | |
associatedtype ResponseType = User | |
func perform(username: String, callback: (User?, ErrorType?) -> Void) | |
} | |
final class FetchUser: FetchUserType { | |
typealias ResponseType = User | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Alamofire | |
import SwiftyJSON | |
protocol NetworkRequest { | |
associatedtype ResponseType | |
// Required | |
var endpoint: String { get } | |
var responseHandler: NSData -> ResponseType? { get } | |