Skip to content

Instantly share code, notes, and snippets.

Avatar

Chelsea Troy chelseatroy

View GitHub Profile
@chelseatroy
chelseatroy / AppDelegate.swift
Created May 8, 2016
Code-Only UI Demonstration: AppDelegate
View AppDelegate.swift
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
//let splitViewController = self.window!.rootViewController as! UISplitViewController
//splitViewController.delegate = self
let window = UIWindow(frame: UIScreen.mainScreen().bounds)
self.window = window
window.rootViewController = MasterViewController()
window.makeKeyAndVisible()
@chelseatroy
chelseatroy / MasterViewController.swift
Created May 8, 2016
Code-only UI Demonstration: ViewController
View MasterViewController.swift
class MasterViewController: UIViewController {
var activityIndicatorView: UIActivityIndicatorView = UIActivityIndicatorView()
var baseView: UIView = UIView()
override func viewDidLoad() {
super.viewDidLoad()
baseView.frame = CGRect.zero;
baseView.translatesAutoresizingMaskIntoConstraints = false
View Airport Integration Flow
@Configuration
@EnableIntegration
public class ExampleConfiguration {
@Bean
IntegrationFlow inboundFlow(
ErrorManager errorManager,
SeatSelector seatSelector,
Prioritizer priority
) {
View onLoadFinished with two cursor loaders
@Override
public void onLoadFinished(Loader<Cursor> loader, final Cursor data) {
switch (loader.getId()) {
case FRUIT_LOADER:
//do things with the fruits data
break;
case VEGGIE_LOADER:
//do things with the vegetables data
break;
}
View onCreateLoader with two cursor loaders, complete
public class NutritionFactFragment extends Fragment implements LoaderManager.LoaderCallbacks<Cursor> {
public static final int FRUIT_LOADER = 1;
public static final int VEGGIE_LOADER = 2;
...
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
switch (id) {
case FRUIT_LOADER:
View onCreateLoader with two cursor loaders, incomplete
public class NutritionFactFragment extends Fragment implements LoaderManager.LoaderCallbacks<Cursor> {
public static final int FRUIT_LOADER = 1;
public static final int VEGGIE_LOADER = 2;
...
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
switch (id) {
case FRUIT_LOADER:
View ExampleViewControllerTest.swift
func testNavigateToView_loadsView() {
let controller = ExampleViewController.loadFromStoryboard()
assertThat(controller.view, present())
UIWindow.present(viewController: controller) { () in
assertThat(controller.someTextLabel.text, presentAnd(equalTo("Why hello there!")))
}
}
@chelseatroy
chelseatroy / ExampleViewController.swift
Last active Sep 7, 2016
View Controller for Testing with Storyboard
View ExampleViewController.swift
class ExampleViewController: UITableViewController {
@IBOutlet var someTextLabel: UITextLabel!
class func loadFromStoryboard() -> ExampleViewController
{
let controller = UIStoryboard(name:"Main", bundle:NSBundle(forClass:self))
.instantiateViewControllerWithIdentifier("ExampleViewController")
as! ExampleViewController
@chelseatroy
chelseatroy / ExampleViewControllerTest.swift
Created Sep 7, 2016
View Controller Dependency Injection Test
View ExampleViewControllerTest.swift
class ExampleViewControllerTest: XCTestCase {
class FakeDependableService: DependableService {
var lastRequestParameter: String?
var stubbedResponse: DependableResponse?
init() {
super.init()
self.lastRequestParameter = ""
self.stubbedResponse = nil
@chelseatroy
chelseatroy / AppEnvironment.swift
Created Sep 7, 2016
View Controller Dependency Injection App Environment
View AppEnvironment.swift
class AppEnviroment: NSObject {
static let sharedEnvironment = AppEnviroment()
let dependableService:DependableService
override init() {
self.dependableService = DependableService()
super.init()