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 RealmSwift | |
import Realm | |
protocol CascadeDeleting: class { | |
func delete<Entity>(_ list: List<Entity>, cascading: Bool) | |
func delete<Entity>(_ results: Results<Entity>, cascading: Bool) | |
func delete<Entity: Object>(_ entity: Entity, cascading: Bool) | |
} |
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
// | |
// SKMultilineLabel.swift | |
// | |
// Created by Craig on 10/04/2015. | |
// Copyright (c) 2015 Interactive Coconut. | |
// MIT License, http://www.opensource.org/licenses/mit-license.php | |
// | |
/* USE: | |
(most component parameters have defaults) | |
let multiLabel = SKMultilineLabel(text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", labelWidth: 250, pos: CGPoint(x: size.width / 2, y: size.height / 2)) |
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 UICollectionView { | |
public func dequeueReusableCell<T:UICollectionViewCell>(type: T.Type, indexPath: NSIndexPath) -> T { | |
let collectionCell : T | |
let cellIdentifier = String(T) | |
if let _ = NSBundle(forClass: T.classForCoder()).pathForResource(cellIdentifier, ofType:"nib") { | |
registerNib(UINib(nibName: cellIdentifier, bundle: nil), forCellWithReuseIdentifier: cellIdentifier) | |
collectionCell = dequeueReusableCellWithReuseIdentifier(cellIdentifier, forIndexPath: indexPath) as! 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
class EventFeed: Hashable, Equatable { | |
var eventId = 0 | |
var hashValue : Int { return eventId } | |
} | |
func ==(lhs: EventFeed, rhs: EventFeed) -> Bool { | |
return lhs.eventId == rhs.eventId | |
} | |
class PostUpload : EventFeed { |
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 UIViewController { | |
func supportedInterfaceOrientations() -> UIInterfaceOrientationMask { | |
if let nvc = self as? UINavigationController { | |
return nvc.topViewController!.supportedInterfaceOrientations() | |
} else { | |
return .Portrait | |
} | |
} |
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 Foundation | |
import UIKit | |
extension UINavigationController { | |
public override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask { | |
if let visibleViewController = visibleViewController { | |
return visibleViewController.supportedInterfaceOrientations() | |
} else if let topViewController = topViewController { |
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 UITableView { | |
public func dequeueReusableCell<T:UITableViewCell>(type: T.Type) -> T { | |
let tableCell : T | |
let cellIdentifier = String(T) | |
if let cell = self.dequeueReusableCellWithIdentifier(cellIdentifier) as? T { | |
tableCell = cell | |
} else if let _ = NSBundle(forClass: T.classForCoder()).pathForResource(cellIdentifier, ofType:"nib") { | |
self.registerNib(UINib(nibName: cellIdentifier, bundle: nil), forCellReuseIdentifier: cellIdentifier) |
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 UIKit | |
extension UIViewController { | |
func setTabBarVisible(visible:Bool, animated:Bool) { | |
//* This cannot be called before viewDidLayoutSubviews(), because the frame is not set before this time | |
// bail if the current state matches the desired state | |
if (tabBarIsVisible() == visible) { return } |