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 Foundation | |
import Combine | |
import Logging | |
// swiftlint:disable empty_count | |
protocol DuplicatableCoreDataEntity { | |
var asyncID: String { get async throws} | |
func setDuplicatedID() async throws -> String |
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
enum JSONDecodingError: Error { | |
case decodingError(DecodingError) | |
case unknown | |
} | |
extension DecodingError { | |
var stringValue: String { | |
switch self { | |
case .valueNotFound(let value, let context): | |
return "Value '\(value)' not found:" + context.debugDescription + "codingPath:" + context.codingPath.map { $0.stringValue }.joined(by: "<->") |
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
// MARK: Demontration of Usage of Injection system | |
// 1. First step: make the key object, the current value type is the one you are trying to add to injection system. | |
private struct BaseClassKey: InjectionKey { | |
static var currentValue: BaseClass = RealSubClass() | |
} | |
// 2. How to inject the currect value | |
func test() { | |
var dataController = TestDataStructure() |
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 CoreData | |
import Foundation | |
protocol CoreDataManager { | |
var uiContext: NSManagedObjectContext { get } | |
func newBackgroundContext() -> NSManagedObjectContext | |
func performBackgroundTaskOnUI(_ block: @escaping (NSManagedObjectContext) -> Void) | |
func performBackgroundTask(_ block: @escaping (NSManagedObjectContext) -> Void) | |
func loadStore(completionHandler: ((Error?) -> Void)?) | |
} |
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
// | |
// BMW Motorrad Connected App for iOS | |
// | |
// Copyright © 2022 BMW Group. All rights reserved. | |
// | |
import Foundation | |
import SwiftUI | |
import WidgetKit | |
struct WidgetSmallView: View { |
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 | |
import Combine | |
struct ContentView: View { | |
class ViewModel: ObservableObject { | |
var bag = Set<AnyCancellable>() | |
init() { | |
fetchFeeds() | |
.tryCatch({ err -> AnyPublisher<Int, Error> in |
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
enum TintFont { | |
enum TypeFace { | |
case bold | |
case boldItalic | |
case book | |
case bookItalic | |
case medium | |
case mediumItalic |
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
class ViewModel: ObservableObject { | |
var bag = Set<AnyCancellable>() | |
var t = "hellow" | |
init() { | |
let mainPublisher = [3, 2, 1].publisher | |
mainPublisher.flatMap({ value in | |
printit(value).map { calcualted in | |
return (value, calcualted) | |
} | |
}) |
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
struct SizeArrayKey: PreferenceKey { | |
static var defaultValue: [CGSize] = [] | |
static func reduce(value: inout Value, nextValue: () -> Value ) { | |
value.append(contentsOf: nextValue()) | |
} | |
} | |
struct Item: Identifiable { | |
var 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
// | |
// ContentView.swift | |
// testswiftUI | |
// | |
// Created by Arash on 2021-06-10. | |
// | |
import SwiftUI | |
struct ContentView: View { |
NewerOlder