Skip to content

Instantly share code, notes, and snippets.

@TerjeLon
TerjeLon / SpotifyAPIManager.swift
Last active August 4, 2022 20:12
Spotify managing
//
// SpotifyAPIManager.swift
// Musock
//
// Created by Terje Lønøy on 02/08/2022.
//
import Foundation
class SpotifyAPIManager {
@TerjeLon
TerjeLon / PreviewPublishedPropertyWrapper.swift
Created April 22, 2022 08:09
Property wrapper for changing published values when in SwiftUI Preview mode
import Foundation
import Combine
@propertyWrapper
public class PreviewPublisher<Value> {
let isPreview = ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1"
private var defaultValue: Value
private var previewValue: Value
private let innerSubject = PassthroughSubject<Value, Never>()
@TerjeLon
TerjeLon / PreviewPropertyWrapper.swift
Created April 22, 2022 08:07
Property wrapper for changing value when in SwiftUI Preview mode
import Foundation
@propertyWrapper public struct Preview<Value> {
let isPreview = ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1"
public var wrappedValue: Value {
get {
return isPreview ? previewValue : defaultValue
}
set {
@propertyWrapper struct Debug<Value> {
var wrappedValue: Value {
get {
#if DEBUG
return debugValue
#else
return defaultValue
#endif
}
set {