xcrun simctl --set previews delete all
xcrun simctl delete unavailable
| extension NSNotification.Name { | |
| public static let deviceDidShakeNotification = NSNotification.Name("MyDeviceDidShakeNotification") | |
| } | |
| extension UIWindow { | |
| open override func motionEnded(_ motion: UIEvent.EventSubtype, with event: UIEvent?) { | |
| super.motionEnded(motion, with: event) | |
| NotificationCenter.default.post(name: .deviceDidShakeNotification, object: event) | |
| } | |
| } | |
| extension View { |
| enum AsyncError: Error { | |
| case finishedWithoutValue | |
| } | |
| extension AnyPublisher { | |
| func async() async throws -> Output { | |
| try await withCheckedThrowingContinuation { continuation in | |
| var cancellable: AnyCancellable? | |
| var finishedWithoutValue = true | |
| cancellable = first() |
| // | |
| // UDPListener.swift | |
| // | |
| // Created by Michael Robert Ellis on 12/16/21. | |
| // | |
| import Foundation | |
| import Network | |
| import Combine |
| // Author: The SwiftUI-Lab | |
| // This code is part of the tutorial: https://swiftui-lab.com/swiftui-animations-part4/ | |
| import SwiftUI | |
| // Sample usage | |
| struct ContentView: View { | |
| var body: some View { | |
| VStack { | |
| GifImage(url: URL(string: "https://media.giphy.com/media/YAlhwn67KT76E/giphy.gif?cid=790b7611b26260b2ad23535a70e343e67443ff80ef623844&rid=giphy.gif&ct=g")!) | |
| .padding(10) |
git rebase -i --rootpick to edit. If you would like to change all the commits, perform the following replace: :%s/^pick/edit/g. This command changes all instances of "pick" at the start of lines to "edit".git rebase --continue.git commit --amend --reset-author. If --reset-author is specified, it will use the details from your git config. (If you need to specify an alternate name/email, you can do so with --author="John Doe <john@example.com>". If you would like to change the time to a previous date, you can do so with --date "2 days ago".)git push -f origin master to| extension AnyPublisher where Failure: Error { | |
| struct Subscriber: Sendable { | |
| fileprivate let send: @Sendable (Output) -> Void | |
| fileprivate let complete: @Sendable (Subscribers.Completion<Failure>) -> Void | |
| func send(_ value: Output) { self.send(value) } | |
| func send(completion: Subscribers.Completion<Failure>) { self.complete(completion) } | |
| } | |
| init(_ closure: (Subscriber) -> AnyCancellable) { |
On Mac, SwiftUI's .onHover closure is not always called on mouse exit, particularly with high cursor velocity. A grid of targets or with finer target shapes will often have multiple targets falsely active after the mouse has moved on.
It is easy to run back to AppKit's safety. Below is a SwiftUI-like modifier for reliable mouse-tracking. You can easily adapt it for other mouse tracking needs.
import SwiftUI| import SwiftUI | |
| struct HalfShape: Shape { | |
| let left: Bool | |
| func path(in rect: CGRect) -> Path { | |
| return Path { path in | |
| let width = rect.width | |
| let height = rect.height |