Skip to content

Instantly share code, notes, and snippets.

View aduuub's full-sized avatar

Adam aduuub

View GitHub Profile
e -l Swift -- let $brokenView = unsafeBitCast(0x7fc5deca3910, to: UIView.self)
e -l Swift -- print($brokenView)
// <UIView: 0x7fc5df0a9400; frame = (0 55; 375 585); .....>
// We could highlight it to make it easier to find
e -l Swift -- $label.backgroundColor = .red
// Or update its text
e -l Swift -- $label.text = "This is new text for a label"
@aduuub
aduuub / LLDBTutorial-3.swift
Last active March 28, 2020 00:19
LLDBTutorial-3.swift
// We can also print it's constraints
e -l Swift -- print($label.constraints)
// [<NSContentSizeLayoutConstraint:0x6000031550e0 UILabel:0x7f913f90b7e0'All skills'.width == 95.5 Hug:251 CompressionResistance:750 (active)>, <NSContentSizeLayoutConstraint:0x600003155140 UILabel:0x7f913f90b7e0'All skills'.height == 33.5 Hug:251 CompressionResistance:750 (active)>]
// Or even modify its priorities
e -l Swift -- $label.constraints[0].constant = 100
e -l Swift -- import MyNotesApp
e -l Swift -- let $syncView = unsafeBitCast(0x6000031550e0, to: SyncView.self)
// Read custom properties
e -l Swift -- print($syncView.syncState)
// Call your custom functions
e -l Swift -- $syncView.showSyncCompleted()
class BaseViewController: UIViewController {
var loadingView: UIView?
/// Called when the interactive view controller popping gesture is attempted from the right hand side.
/// The view controller should override this if it wants to change its behaviour.
///
/// - Returns: true if you want to prevent the interactive gesture.
func preventInteractivePopGesture() -> Bool {
let isNavBarVisible: Bool = navController?.isNavigationBarHidden == false
internal class BaseNavigationController: UINavigationController {
/// Indicates if a UIViewController is currently being pushed onto this navigation controller
private var duringPushAnimation = false
override func viewDidLoad() {
super.viewDidLoad()
self.delegate = self // to track when a view controller is being pushed
self.interactivePopGestureRecognizer?.delegate = self // for swipe the pop gesture recogniser
}
extension BaseNavigationController: UINavigationControllerDelegate {
func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {
(navigationController as? BaseNavigationController)?.duringPushAnimation = false
}
}
extension BaseNavigationController: UIGestureRecognizerDelegate {
func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
guard gestureRecognizer == interactivePopGestureRecognizer else {
return true // default value
}
// Disable pop gesture in three situations:
// 1) the view controller doesn't support being popped or doesn't want to be popped right now
//
// KeyboardLayoutConstraint.swift
// TemplateProject
//
// Created by Adam Wareing on 12/08/19.
// Licenced under MIT.
//
// Based off: https://raw.githubusercontent.com/MengTo/Spring/master/Spring/KeyboardLayoutConstraint.swift
import UIKit
@aduuub
aduuub / ViewModel.swift
Created August 13, 2023 08:26
Generic ViewModel
//
// TestViewModel.swift
// Test
//
// Created by Adam Wareing on 11/8/2023.
//
import UIKit
/// Model for storing a section and its contents