This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///copy the implementation of NSObject.init and exchange it with some new fake init we are going to create. | |
///https://nshint.io/blog/2019/04/08/testing-the-camera-on-the-simulator/ | |
///https://pspdfkit.com/blog/2019/swizzling-in-swift/ | |
private struct Swizzler { | |
private let klass: AnyClass | |
init(_ klass: AnyClass) { | |
self.klass = klass | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PlaygroundSupport | |
class Node { | |
var data: Int | |
var next: Node? | |
init(data: Int) { | |
self.data = data | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
class A { | |
func call(selector: Selector, on destination: Any) { | |
if let object = destination as? NSObject { | |
object.performSelector(onMainThread: selector, with: self, waitUntilDone: true) | |
} else { | |
DispatchQueue.main.async { | |
Thread.detachNewThreadSelector(selector, toTarget: destination, with: self) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
protocol MyNotificationCenterInterface { | |
func addObserver(_ observer: Any, selector: Selector, name: NSNotification.Name?, object: Any?) | |
func post(_ notification: Notification) | |
} | |
struct NotificationObserverData { | |
let observer: Any, | |
selector: Selector, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
class TreeNode { | |
var data: Int | |
var left: TreeNode? | |
var right: TreeNode? | |
init(data: Int) { | |
self.data = data | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def configure_branch_settings(target) | |
target.build_configurations.each do |config| | |
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = ['$(inherited)', 'BRANCH_EXCLUDE_IDFA_CODE=1'] | |
end | |
end | |
post_install do |installer| | |
installer.pods_project.targets.each do |target| | |
if target.name == 'Branch' | |
# NOTE: we need to set this in order to compile Branch pod such that it won't call https://developer.apple.com/documentation/adsupport/asidentifiermanager/1614151-advertisingidentifier at runtime. This is to prevent Apple from requiring us to show https://developer.apple.com/documentation/apptrackingtransparency/attrackingmanager to users |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func fixiOS15AppearanceIssues() { | |
fixiOS15NavBarIssues() | |
fixiOS15TabBarIssues() | |
} | |
private func fixiOS15NavBarIssues() { | |
if #available(iOS 15, *) { | |
let appearance = UINavigationBarAppearance() | |
appearance.configureWithOpaqueBackground() | |
appearance.backgroundColor = .blue //customised nav bar background color |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override var preferredStatusBarStyle : UIStatusBarStyle { | |
return .default | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///Remove section header top spacing - https://developer.apple.com/forums/thread/684706 | |
if #available(iOS 15, *) { | |
sectionHeaderTopPadding = 0 | |
} |