Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View ralfebert's full-sized avatar

Ralf Ebert ralfebert

View GitHub Profile
import SwiftUI
import BottomSheet
struct ContentView: View {
@State private var bottomSheetPresented = true
var body: some View {
Color.yellow
.ignoresSafeArea()
.bottomSheet(isPresented: $bottomSheetPresented) {
{
"images" : [
{
"filename" : "icon_20pt@2x.png",
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20"
},
{
"filename" : "icon_20pt@3x.png",
import Foundation
import CoreData
extension NSPersistentContainer {
typealias ErrorHandler = (NSError) -> Void
convenience init(defaultContainerWithName name : String, inMemory : Bool = false, errorHandler : ErrorHandler? = nil) {
self.init(name: name)
import Foundation
import SwiftUI
struct IndexedCollection<Base: RandomAccessCollection>: RandomAccessCollection {
typealias Index = Base.Index
typealias Element = (index: Index, element: Base.Element)
let base: Base
var startIndex: Index { self.base.startIndex }
var endIndex: Index { self.base.endIndex }
func index(after i: Index) -> Index {

FB9165511: Swift compiler accepts an invalid circular reference in some conditions

The following code example doesn't compile because of the circular reference. Except if you uncomment the line that uses the weak self. It's still an invalid circular reference, but all of a sudden the compiler accepts it. Happens with Xcode 12.5 and 13 Beta 1.

class Flupp {
    init() {
        print("Flupp!")
    }
 deinit {
struct Format {
/// 12.03.2021
static let mediumDate: DateFormatter = {
let formatter = DateFormatter()
formatter.dateStyle = .medium
return formatter
}()
/// 12.03.2021 12:34
// based on https://sarunw.com/posts/how-to-sort-by-multiple-properties-in-swift/
struct BlogPost {
let title: String
let pageView: Int
let sessionDuration: Double
}
extension BlogPost {
static var examples: [BlogPost] = [
extension Comparable {
mutating func clamp(_ limits: ClosedRange<Self>) {
self = min(max(self, limits.lowerBound), limits.upperBound)
}
mutating func clamp(_ limits: PartialRangeFrom<Self>) {
self = max(self, limits.lowerBound)
}
mutating func clamp(_ limits: PartialRangeThrough<Self>) {
self = min(self, limits.upperBound)
}
import CoreHaptics
import SwiftUI
enum FeedbackType {
case selection, success, error
}
class Haptics {
@AppStorage("HaptikFeedbackEnabled") var haptikFeedbackEnabled = true

Components

See also