Skip to content

Instantly share code, notes, and snippets.

View alongotv's full-sized avatar
💭
Hello everybody!

Vladimir alongotv

💭
Hello everybody!
  • Saint-Petersburg, RU
View GitHub Profile
@alongotv
alongotv / OnDidAppearSwiftUI
Last active November 11, 2024 14:07
Adds viewDidAppear callback to SwiftUI
struct ViewControllerLifecycleHandler: UIViewControllerRepresentable {
func makeCoordinator() -> ViewControllerLifecycleHandler.Coordinator {
Coordinator(onDidAppear: onDidAppear)
}
let onDidAppear: () -> Void
func makeUIViewController(context: UIViewControllerRepresentableContext<ViewControllerLifecycleHandler>) -> UIViewController {
context.coordinator
}
@alongotv
alongotv / UrlParameters.swift
Last active August 30, 2022 07:29
Removes obsolete parameters from URL
/*
Usage:
let urlString = "https://example.com/?foo=bar&param2=none&__is_cowboy=false"
let url = URL(string: urlString)
let urlWithoutParameters = url?.removeParameters(with: ["param2", "__is_cowboy"])
print(urlWithoutParameters!)
Result: https://example.com/?foo=bar is printed
*/