github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

rentzsch / jrswizzle

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 30
    • 5
  • Source
  • Commits
  • Network (5)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (2)
    • v1.0d1
    • v1.0d0
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

one-stop-shop for all your method swizzling needs — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

[DEV] Update README's `git checkout` example to v1.0d1. 
rentzsch (author)
Sun May 31 14:19:48 -0700 2009
commit  785af40f073c13b9245a624da3d06e16e146b331
tree    b655379578077f3629c9fbc76d777eae72139d79
parent  4c870650da2b6100eee52eadea6b3c6af7996ce8
jrswizzle /
name age
history
message
file JRSwizzle.h Thu Apr 09 20:00:16 -0700 2009 [ADMIN] Initial commit (via `svn export http://... [rentzsch]
file JRSwizzle.m Sun May 31 14:07:03 -0700 2009 [FIX] Soothe valgrind by nulling out `hoisted_m... [rentzsch]
directory JRSwizzleTest/ Sun May 31 14:08:47 -0700 2009 [FIX] Xcode 3.2 apparently now needs `ARCHS` se... [rentzsch]
file README.markdown Sun May 31 14:19:48 -0700 2009 [DEV] Update README's `git checkout` example to... [rentzsch]
README.markdown

JRSwizzle

Description

JRSwizzle is source code package that offers a single, easy, correct+consistent interface for exchanging Objective-C method implementations ("method swizzling") across many versions of Mac OS X, Objective-C and runtime architectures.

More succinctly: JRSwizzle wants to be your one-stop-shop for all your method swizzling needs.

Download

$ cd /path/to/top/of/your/project
$ git submodule add git://github.com/rentzsch/jrswizzle.git JRSwizzle
$ git submodule init && git submodule update

# OPTIONAL: Execute the following commands if you want to explicitly peg
# to a certain version. Otherwise `git submodule update` will keep you
# current with HEAD.

$ cd JRSwizzle
$ git checkout v1.0d1

Reasons for Existence

  • Easy: Just do this: [SomeClass jr_swizzle:@selector(foo) withMethod:@selector(my_foo) error:&error]; Voila.
  • Correct: There's a subtle interaction between method swizzling and method inheritance. Following in Kevin Ballard's footsteps, this package Does The Right Thing.
  • Compatible: JRSwizzle should Just Work on any version of Mac OS X you care about. Here's the exhaustive compatibility list:
    • Mac OS X v10.3/ppc (Ballard implementation)
    • Mac OS X v10.4/ppc (Ballard implementation)
    • Mac OS X v10.4/i386 (Ballard implementation)
    • Mac OS X v10.5/ppc (method_exchangeImplementations+Ballard implementation)
    • Mac OS X v10.5/i386 (method_exchangeImplementations+Ballard implementation)
    • Mac OS X v10.5/ppc64 (method_exchangeImplementations+Ballard implementation)
    • Mac OS X v10.5/x86_64 (method_exchangeImplementations+Ballard implementation)
  • Robust: All parameters are checked and JRSwizzle returns an optional NSError with high-quality diagnostics.

Support

Please use JRSwizzle's Lighthouse project site to file bugs or feature requests.

To contribute, please fork this project, make+commit your changes and then send me a pull request.

Comparison

There's at least four swizzling implementations floating around. Here's a comparison chart to help you make sense of how they relate to each other and why JRSwizzle exists.

Scenario Swizzle Technology Method Implementation Correct Behavior 10.4 64-bit
1 Classic Direct YES YES NO
2 Classic Inherited NO YES NO
3 Ballard Direct YES YES NO
4 Ballard Inherited YES YES NO
5 Apple Direct YES NO YES
6 Apple Inherited NO NO YES
7 JRSwizzle Direct YES YES YES
8 JRSwizzle Inherited YES YES YES
  • Classic is the canonical MethodSwizzle() implementation as described in CocoaDev's MethodSwizzling page.
  • Ballard is Kevin Ballard's improved implementation which solves the inherited method problem.
  • Apple is 10.5's new method_exchangeImplementations API.
  • JRSwizzle is this package.

License

The source code is distributed under the nonviral MIT License. It's the simplest most permissive license available.

Version History

  • v1.0d1: May 31 2009

    • [FIX] Soothe valgrind by nulling out hoisted_method_list->obsolete, which it apparently reads. (Daniel Jalkut)

    • [FIX] Xcode 3.2 apparently now needs ARCHS set explicitly for 10.3 targets. (rentzsch)

  • v1.0d0: Apr 09 2009

    • Moved to github.
  • v1.0d0: Dec 28 2007

    • Under development.
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server