Skip to content

Instantly share code, notes, and snippets.

View denis-obukhov's full-sized avatar
📟

Denis Obukhov denis-obukhov

📟
View GitHub Profile
@darrarski
darrarski / SwiftUI_onInterfaceOrientationChange.swift
Created August 23, 2021 10:50
SwiftUI view modifier that performs action when UIInterfaceOrientation changes
import SwiftUI
public extension View {
/// Perform action when interface orientation of the view changes
/// - Parameter perform: Action to perform
/// - Returns: Modified view
func onInterfaceOrientationChange(perform: @escaping (UIInterfaceOrientation) -> Void) -> some View {
modifier(OnInterfaceOrientationChangeViewModifier(onChange: perform))
}
}
@danielmartin
danielmartin / BetterXcodeJumpToCounterpartSwift.org
Last active March 13, 2025 11:08
Add support for a better Xcode's Jump to Next Counterpart in Swift

If you work on a Swift project that follows the Model-View-ViewModel (MVVM) architecture or similar, you may want to jump to counterpart in Xcode from your view to your model, and then to your view model. (ie. by using Ctrl+Cmd+Up and Ctrl+Cmd+Down).

You can do this in recent versions of Xcode by setting a configuration default.

From a terminal, just type this command and press Enter:

defaults write com.apple.dt.Xcode IDEAdditionalCounterpartSuffixes -array-add "ViewModel" "View"