This file contains hidden or 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
| // | |
| // ContentView.swift | |
| // CalculatePi | |
| // | |
| // Created by John Haney on 3/14/24. | |
| // | |
| import SwiftUI | |
| import Combine |
This file contains hidden or 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 SwiftUI | |
| struct Item: Identifiable { | |
| let id = UUID() | |
| var title: String | |
| var details: String | |
| } | |
| struct ItemList: Identifiable { | |
| let id = UUID() |
This file contains hidden or 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
| protocol Transitionable | |
| { | |
| associatedtype State | |
| associatedtype Transition | |
| func nextState(from: State, via: Transition) -> State? | |
| } | |
| extension Transitionable | |
| { | |
| func canTransition(from: State, via: Transition) -> Bool |
This file contains hidden or 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 Array where Element: Equatable { | |
| var uniqueValues: Array<Element> { | |
| get { | |
| var collection = Array<Element>() | |
| for element: Element in self | |
| { | |
| if !collection.contains(element) | |
| { | |
| collection.append(element) |
This file contains hidden or 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
| override func numberOfSectionsInTableView(tableView: UITableView) -> Int | |
| { | |
| return fetchedResultsController.sections?.count ?? 0 | |
| } | |
| override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int | |
| { | |
| return fetchedResultsController.sections?[section].numberOfObjects ?? 0 | |
| } |
This file contains hidden or 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
| typedef void (^JHBlockObservedAction)(NSDictionary *change); | |
| @interface JHBlockObserver : NSObject | |
| @property (copy, nonatomic) JHBlockObservedAction block; | |
| @property (strong, nonatomic) id object; | |
| @property (strong, nonatomic) NSString *keyPath; | |
| + (JHBlockObserver *)observerForObject:(NSObject *)object forKeyPath:(NSString *)keyPath options:(NSKeyValueObservingOptions)options withBlock:(JHBlockObservedAction)block; |