Skip to content

Instantly share code, notes, and snippets.

View chelseatroy's full-sized avatar

Chelsea Troy chelseatroy

View GitHub Profile
@chelseatroy
chelseatroy / AppDelegate.swift
Created May 8, 2016 23:38
Code-Only UI Demonstration: AppDelegate
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 23:57
Code-only UI Demonstration: ViewController
class MasterViewController: UIViewController {
var activityIndicatorView: UIActivityIndicatorView = UIActivityIndicatorView()
var baseView: UIView = UIView()
override func viewDidLoad() {
super.viewDidLoad()
baseView.frame = CGRect.zero;
baseView.translatesAutoresizingMaskIntoConstraints = false
@Configuration
@EnableIntegration
public class ExampleConfiguration {
@Bean
IntegrationFlow inboundFlow(
ErrorManager errorManager,
SeatSelector seatSelector,
Prioritizer priority
) {
@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;
}
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:
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:
@chelseatroy
chelseatroy / ExampleViewControllerTest.swift
Last active September 7, 2016 13:03
View Controller Unit Test
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 September 7, 2016 13:04
View Controller for Testing with Storyboard
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 September 7, 2016 16:49
View Controller Dependency Injection Test
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 September 7, 2016 17:15
View Controller Dependency Injection App Environment
class AppEnviroment: NSObject {
static let sharedEnvironment = AppEnviroment()
let dependableService:DependableService
override init() {
self.dependableService = DependableService()
super.init()