Skip to content

Commit

Permalink
Eliminate a lot of warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
KatherineInCode committed Mar 21, 2024
1 parent 71fd908 commit 78bd500
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 25 deletions.
11 changes: 8 additions & 3 deletions Authenticator/Application/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ struct ContentView: View {

@FetchRequest(
sortDescriptors: [NSSortDescriptor(keyPath: \Item.timestamp, ascending: true)],
animation: .default)
animation: .default
)
private var items: FetchedResults<Item>

var body: some View {
Expand Down Expand Up @@ -44,7 +45,9 @@ struct ContentView: View {
try viewContext.save()
} catch {
// Replace this implementation with code to handle the error appropriately.
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
// fatalError() causes the application to generate a crash log and terminate.
// You should not use this function in a shipping application,
// although it may be useful during development.
let nsError = error as NSError
fatalError("Unresolved error \(nsError), \(nsError.userInfo)")
}
Expand All @@ -59,7 +62,9 @@ struct ContentView: View {
try viewContext.save()
} catch {
// Replace this implementation with code to handle the error appropriately.
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
// fatalError() causes the application to generate a crash log and terminate.
// You should not use this function in a shipping application,
// although it may be useful during development.
let nsError = error as NSError
fatalError("Unresolved error \(nsError), \(nsError.userInfo)")
}
Expand Down
30 changes: 18 additions & 12 deletions Authenticator/Application/Persistence.swift
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import CoreData

struct Persistence {}

struct PersistenceController {
static let shared = PersistenceController()

static var preview: PersistenceController = {
let result = PersistenceController(inMemory: true)
let viewContext = result.container.viewContext
for _ in 0..<10 {
for _ in 0 ..< 10 {
let newItem = Item(context: viewContext)
newItem.timestamp = Date()
}
do {
try viewContext.save()
} catch {
// Replace this implementation with code to handle the error appropriately.
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
// fatalError() causes the application to generate a crash log and terminate.
// You should not use this function in a shipping application, although it may be useful during development.
let nsError = error as NSError
fatalError("Unresolved error \(nsError), \(nsError.userInfo)")
}
Expand All @@ -28,19 +31,22 @@ struct PersistenceController {
if inMemory {
container.persistentStoreDescriptions.first!.url = URL(fileURLWithPath: "/dev/null")
}
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
container.loadPersistentStores(completionHandler: { _, error in
if let error = error as NSError? {
// Replace this implementation with code to handle the error appropriately.
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
// fatalError() causes the application to generate a crash log and terminate.
// You should not use this function in a shipping application,
// although it may be useful during development.

/*
Typical reasons for an error here include:
* The parent directory does not exist, cannot be created, or disallows writing.
* The persistent store is not accessible, due to permissions or data protection when the device is locked.
* The device is out of space.
* The store could not be migrated to the current model version.
Check the error message to determine what the actual problem was.
*/
//
// Typical reasons for an error here include:
// * The parent directory does not exist, cannot be created, or disallows writing.
// * The persistent store is not accessible,
// due to permissions or data protection when the device is locked.
// * The device is out of space.
// * The store could not be migrated to the current model version.
// Check the error message to determine what the actual problem was.
//
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ public extension Coordinator {
func asAnyCoordinator() -> AnyCoordinator<Route> {
AnyCoordinator(self)
}
}
}
2 changes: 1 addition & 1 deletion AuthenticatorShared/Application/Utilities/Command.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ public struct Command<Action: Sendable, State: Sendable>: Sendable {
/// A closure that will asynchronously send an `Action` to the store. This may be used to
/// communicate changes that should occur as a result of performing the command.
public let send: @Sendable (Action) async -> Void
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ public extension Coordinator {
func navigate(to route: Route) {
navigate(to: route, context: nil)
}
}
}
2 changes: 1 addition & 1 deletion AuthenticatorShared/Application/Utilities/Navigator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import SwiftUI

/// A protocol for an object that can navigate between screens and show alerts.
@MainActor
public protocol Navigator: AnyObject {}
public protocol Navigator: AnyObject {}
2 changes: 1 addition & 1 deletion AuthenticatorShared/Application/Utilities/Processor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ public protocol Processor: AnyObject, Sendable {
/// - Parameter action: The action to process.
///
func receive(_ action: Action)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ public protocol RootNavigator: Navigator {
///
/// - Parameter child: The navigator to show.
func show(child: Navigator?)
}
}
2 changes: 1 addition & 1 deletion AuthenticatorShared/Application/Utilities/Route.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/// A top level route from the initial screen of the app to anywhere in the app.
///
public enum Route: Equatable {}
public enum Route: Equatable {}
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,4 @@ extension UINavigationController: StackNavigator {
public func replace<Content: View>(_ view: Content, animated: Bool) {
setViewControllers([UIHostingController(rootView: view)], animated: animated)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ open class StateProcessor<Action: Sendable, State: Sendable, Effect: Sendable>:
/// - Parameter action: The action to process.
///
open func receive(_ action: Action) {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ extension UITabBarController: TabNavigator {
public func navigator<Tab: RawRepresentable>(for tab: Tab) -> Navigator? where Tab.RawValue == Int {
viewControllers?[tab.rawValue] as? Navigator
}
}
}

0 comments on commit 78bd500

Please sign in to comment.