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 | |
@objc protocol SelectorContext { | |
var selector: Selector { get } | |
func selectorCallback(_ sender: Any) | |
} | |
extension UIViewController: SelectorContext { |
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 SelectorDemoViewController: UIViewController { | |
override func viewDidLoad() { | |
NotificationCenter.default.addObserver(self, | |
selector: selector, | |
name: kUnwindNotification, | |
object: nil) | |
} | |
} |
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
public struct Stack<Element> | |
{ | |
fileprivate var stackItems: [Element] = [Element]() | |
public init() {} | |
public mutating func pop() -> Element? { | |
guard !stackItems.isEmpty else { | |
return nil |
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 CoreData | |
public class ModelController { | |
typealias VoidCompletion = () -> () | |
// MARK: - Properties | |
private var modelName: String = Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as? String ?? "" | |
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 ModelController { | |
func add<M: NSManagedObject>(_ type: M.Type) -> M? { | |
var modelObject: M? | |
if let entity = NSEntityDescription.entity(forEntityName: M.description(), in: context) { | |
modelObject = M(entity: entity, insertInto: context) | |
} | |
return modelObject |
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 ModelController { | |
func total<M: NSManagedObject>(_ type: M.Type) -> Int { | |
let entityName = String(describing: type) | |
let request = NSFetchRequest<M>(entityName: entityName) | |
do { | |
let count = try context.count(for: request) | |
return count |
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 ModelController { | |
func save() { | |
if context.hasChanges { | |
do { | |
try context.save() | |
} catch { | |
let nserror = error as NSError | |
fatalError("Unresolved error \(nserror), \(nserror.userInfo)") | |
} |
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 ModelController { | |
func delete(by objectID: NSManagedObjectID) { | |
let managedObject = context.object(with: objectID) | |
context.delete(managedObject) | |
} | |
func delete<M: NSManagedObject>(_ type: M.Type, predicate: NSPredicate?=nil) { | |
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 React, { FC } from 'react'; | |
import { ViewProps } from 'react-native'; | |
import styled from 'styled-components/native'; | |
import { ThemeInterface } from 'themes/ThemeInterface'; | |
interface IBoxProps extends ViewProps { | |
theme?: ThemeInterface; | |
borders?: boolean; | |
} |
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 React, { FC } from 'react'; | |
import { ViewProps } from 'react-native'; | |
import styled from 'styled-components/native'; | |
import { ThemeInterface } from 'themes/ThemeInterface'; | |
interface IBoxProps extends ViewProps { | |
theme?: ThemeInterface; | |
borders?: boolean; | |
} |
OlderNewer