Skip to content

Instantly share code, notes, and snippets.

danielgarbien

View GitHub Profile
View SafeFetchedResultsController.swift
import Foundation
import CoreData
class SafeFetchedResultsController: NSFetchedResultsController {
private weak var safeDelegate: NSFetchedResultsControllerDelegate?
override var delegate: NSFetchedResultsControllerDelegate? {
get {
return safeDelegate
View ContainmentWithAutoLayout.swift
import UIKit
extension UIViewController {
/**
Add childController with no transition.
Embeds its view in container.
Calls didMove(toParentViewController:) on childController at a last step.
*/
func addImmediately(childController: UIViewController, embeddedIn container: UIView) {
View FetchedResultsTableDataSource.swift
import Foundation
import UIKit
import CoreData
class FetchedResultsTableDataSource: NSObject {
typealias CellForRowAtIndexPath = (tableView: UITableView, indexPath: NSIndexPath, object: AnyObject) -> UITableViewCell
let fetchedResultController: NSFetchedResultsController
private let cellForRowAtIndexPath: CellForRowAtIndexPath
View CoreDataStack.swift
import Foundation
import CoreData
class CoreDataStack {
let mainContext: NSManagedObjectContext
private let persistentStoreCoordinator: NSPersistentStoreCoordinator
private let managedObjectModel: NSManagedObjectModel
View FetchedResultsControllerTableDelegate.swift
import Foundation
import UIKit
import CoreData
class FetchedResultsControllerTableDelegate: NSObject {
let tableView: UITableView
var preserveSelection: Bool = true
var didEndUpdates: (() -> Void)?
View KeyboardAwareScrollViewCoordinator.swift
import Foundation
import UIKit
/**
* Coordinates contentInset on scroll view to always show full content on keyboard appearing.
*/
class KeyboardAwareScrollViewCoordinator: NSObject {
let scrollView: UIScrollView
private let originalContentInset: UIEdgeInsets
You can’t perform that action at this time.