Skip to content

Instantly share code, notes, and snippets.

View rxtr007's full-sized avatar
🎯
Focusing

Sachin Ambegave rxtr007

🎯
Focusing
View GitHub Profile
extension UIHostingController {
convenience public init(rootView: Content, ignoreSafeArea: Bool) {
self.init(rootView: rootView)
if ignoreSafeArea {
disableSafeArea()
}
}
func disableSafeArea() {
//
// ContentView.swift
// navigation
//
// Created by Thomas Ricouard on 13/10/2019.
// Copyright © 2019 Thomas Ricouard. All rights reserved.
//
import SwiftUI
@caiozullo
caiozullo / Careful With “Singleton” Lookalikes episode.swift
Created November 12, 2018 10:55
Careful With “Singleton” Lookalikes episode
//
// Copyright © 2018 Essential Developer. All rights reserved.
//
import UIKit
/*
The Singleton design pattern is intended to enforce
a class has only one instance.
@haversnail
haversnail / UIColor+Hex.swift
Created May 30, 2017 05:01
A Swift UIColor extension adding hex color code support.
//
// UIColor+Hex.swift
// Gist
//
// Created by Alexander Havermale on 5/26/17.
// Copyright © 2017 Alex Havermale. All rights reserved.
//
import UIKit
@steipete
steipete / ios-xcode-device-support.sh
Last active December 12, 2023 03:36
Using iOS 15 devices with Xcode 12.5 (instead of Xcode 13)
# The trick is to link the DeviceSupport folder from the beta to the stable version.
# sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :)
# Support iOS 15 devices (Xcode 13.0) with Xcode 12.5:
sudo ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/15.0 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
# Then restart Xcode and reconnect your devices. You will need to do that for every beta of future iOS versions
# (A similar approach works for older versions too, just change the version number after DeviceSupport)
@steipete
steipete / PSPDFUIKitMainThreadGuard.m
Last active March 10, 2024 19:23
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
// PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit.
#import <objc/runtime.h>
#import <objc/message.h>