All Projects → MarioIannotta → Swizzleswift

MarioIannotta / Swizzleswift

Licence: mit
Swizzle selectors with just one clean and elegant API

Programming Languages

swift
15916 projects

Labels

Projects that are alternatives of or similar to Swizzleswift

Napajs
Napa.js: a multi-threaded JavaScript runtime
Stars: ✭ 8,945 (+6289.29%)
Mutual labels:  runtime
Quickjs
The official repo is at bellard/quickjs.
Stars: ✭ 1,429 (+920.71%)
Mutual labels:  runtime
Runtypes
Runtime validation for static types
Stars: ✭ 1,950 (+1292.86%)
Mutual labels:  runtime
Swifthook
A library to hook methods in Swift and Objective-C.
Stars: ✭ 93 (-33.57%)
Mutual labels:  runtime
Redtamarin
AS3 running on the command line / server side
Stars: ✭ 105 (-25%)
Mutual labels:  runtime
Readyforbat
慕课网iOS面试实战项目总结:iOS面试题思维导图与回答
Stars: ✭ 1,569 (+1020.71%)
Mutual labels:  runtime
Arcgis Appstudio Samples
Collection of samples available in AppStudio for ArcGIS desktop to learn and help build your next app.
Stars: ✭ 78 (-44.29%)
Mutual labels:  runtime
Next Runtime Dotenv
Expose environment variables to the runtime config of Next.js
Stars: ✭ 136 (-2.86%)
Mutual labels:  runtime
Webworkify Webpack
launch a web worker at runtime that can require() in the browser with webpack
Stars: ✭ 105 (-25%)
Mutual labels:  runtime
Dotnetbook
.NET Platform Architecture book (English, Chinese, Russian)
Stars: ✭ 1,763 (+1159.29%)
Mutual labels:  runtime
Charm
The Charm++ parallel programming system. Visit https://charmplusplus.org/ for more information.
Stars: ✭ 96 (-31.43%)
Mutual labels:  runtime
Icmethoddigger
An easy way to print almost methods including private methods (supported arm64 architecture devices).
Stars: ✭ 103 (-26.43%)
Mutual labels:  runtime
Nuclei
Proactive IO & Runtime system
Stars: ✭ 113 (-19.29%)
Mutual labels:  runtime
Mulle Objc Runtime
⏩ A fast, portable Objective-C runtime written 100% in C11
Stars: ✭ 90 (-35.71%)
Mutual labels:  runtime
Electron Global
One Electron instance for multiple apps
Stars: ✭ 129 (-7.86%)
Mutual labels:  runtime
Client
An alternative Polkadot Runtime Environment implementation acting as a full-node (excluding block production for validators) for syncing with Substrate-based chains.
Stars: ✭ 82 (-41.43%)
Mutual labels:  runtime
Apple Juice Actionscript
Pure .NET 2.0 code Implementation of the ActionScript3 compiler and runtime. Can be used to run scripts in environments where "just-in-time compilation" is not possible
Stars: ✭ 112 (-20%)
Mutual labels:  runtime
Nconcern
NConcern .NET AOP Framework
Stars: ✭ 139 (-0.71%)
Mutual labels:  runtime
Debugengine
Delphi debug framework
Stars: ✭ 133 (-5%)
Mutual labels:  runtime
Lunatic
Lunatic is an Erlang-inspired runtime for WebAssembly
Stars: ✭ 2,074 (+1381.43%)
Mutual labels:  runtime

SwizzleSwift

Who said that method swizzling needs to look ugly? SwizzleSwift is a little wrapper that lets you swizzle selectors just one clean and elegant API.

SwizzleSwift: Swizzle selectors with just one clean and elegant API

Version License Platform

Installation

Pods

pod 'SwizzleSwift'

Swift package manager

From Xcode, select File → Swift Packages → Add Package Dependency → Select your project → Search SwizzleSwift

Usage example

Swizzle(<#AType.Self#>) {
	<#OriginalSelector#> <-> <#SwizzledSelector#>
}

Given the following controller

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        print(#function)
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        print(#function)
    }

}

extension UIViewController {

    @objc private func myViewDidLoad() {
        print(#function)
        myViewDidLoad()
    }
    
    @objc private func myViewWillAppear(_ animated: Bool) {
        print(#function)
        myViewWillAppear(animated)
    }
    
}

Swizzling the methods like this

extension UIViewController {

    @objc static func methodSwizzling() -> Void {
        Swizzle(ViewController.self) {
            #selector(viewDidLoad) <-> #selector(myViewDidLoad)
            #selector(viewWillAppear(_:)) <-> #selector(myViewWillAppear(_:))
        }
    }
    
}

Will produce the following output

myViewDidLoad()
viewDidLoad()
myViewWillAppear(_:)
viewWillAppear(_:)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].