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
@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
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
- (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
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
struct Person { | |
var firstName: String | |
var lastName: String | |
var age: String | |
} | |
let person = Person(firstName: "Austin", lastName: "Feight", age: -3) | |
UserDefaults.standard.set(person) | |
let fetchedPerson = UserDefaults.standard.fetch(Person.self) |
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
extension Person: DefaultConvertible { | |
private static let firstNameKey = "first_name" | |
private static let lastNameKey = "last_name" | |
private static let ageKey = "age" | |
var serialized: [String : AnyObject] { | |
return | |
[ | |
Person.firstNameKey: firstName as AnyObject, | |
Person.lastNameKey: lastName as AnyObject, |
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
let defaults = Defaults() | |
let person = Person(firstName: "Austin", lastName: "Feight", age: -3) | |
defaults.save(person) | |
let fetched: Person? = defaults.fetch(Person.self) | |
print("\(fetched!.firstName) \(fetched!.lastName) is \(fetched!.age) years old") | |
// Output: Austin Feight is -3 years old |
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
let defaults = Defaults() | |
let hasLoggedIn = true | |
defaults.save(true, forKey: .LoggedIn) | |
defaults.save(false, forKey: .NotificationsEnabled) | |
let regularOrder = Order(item: "Cold Brew", size: .Large) | |
let alternateOrder = Order(item: "Latte", size: .Small) | |
defaults.save(regularOrder) | |
defaults.save(alternateOrder, forKey: .Alternate) |