-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
33 additions
and
32 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,60 @@ | ||
OCFuntime | ||
============ | ||
|
||
## About | ||
#### About | ||
[![Build Status](https://travis-ci.org/belkevich/ocfuntime.png?branch=develop)](https://travis-ci.org/belkevich/ocfuntime) | ||
|
||
OCFuntime is a simple wrapper on [Objective-C runtime](https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html). So if you don't know the easiest way to shoot off your both legs then this solution for you! Time to have a fun! | ||
|
||
--- | ||
|
||
## Installation | ||
**Install via [cocoapods](http://cocoapods.org/)** | ||
Include `ocfuntime` pod in you Podfile | ||
#### Features | ||
* Change instance method implementation | ||
* Change class method implementation | ||
* Return value of any type or don't return anything | ||
* Revert to default method implementation | ||
|
||
#### Installation | ||
Include `ocfuntime` pod in Podfile | ||
|
||
--- | ||
|
||
## Using | ||
**Create funtime instance** | ||
#### Using | ||
```objective-c | ||
OCFuntime *funtime = [[OCFuntime alloc] init]; | ||
``` | ||
|
||
**Change instance method implementation** | ||
```objective-c | ||
[funtime changeClass:[MyClass class] instanceMethod:@selector(instanceMethod) implementation:^ | ||
// Change instance method implementation | ||
[funtime changeClass:[MyClass class] instanceMethod:@selector(someInstanceMethod) | ||
implementation:^ | ||
{ | ||
NSLog(@"Changed FUN instance method!"); | ||
return 1; | ||
}]; | ||
``` | ||
**Change class method implementation** | ||
```objective-c | ||
[funtime changeClass:[MyClass class] classMethod:@selector(classMethod) implementation:^ | ||
// Change class method implementation | ||
[funtime changeClass:[MyClass class] classMethod:@selector(someClassMethod) | ||
implementation:^ | ||
{ | ||
NSLog(@"Changed FUN class method!"); | ||
return [[NSObject alloc] init]; | ||
}]; | ||
``` | ||
|
||
**Revert method to default implementation** | ||
```objective-c | ||
[funtime revertClass:[MyClass class] method:@selector(method)]; | ||
``` | ||
**Revert all methods of class to default implementation** | ||
```objective-c | ||
//Revert method to default implementation | ||
[funtime revertClass:[MyClass class] instanceMethod:@selector(someInstanceMethod)]; | ||
[funtime revertClass:[MyClass class] classMethod:@selector(somClassMethod)]; | ||
// Revert all methods of class to default implementation | ||
[funtime revertClass:[MyClass class]]; | ||
``` | ||
|
||
**Revert all changed methods to default implementation** | ||
```objective-c | ||
// Revert all changed methods to default implementation | ||
[funtime revertAll]; | ||
``` | ||
--- | ||
## Updates | ||
#### Changes | ||
[@okolodev](https://twitter.com/okolodev) | ||
--- | ||
## Spec status | ||
![Build status](https://api.travis-ci.org/belkevich/ocfuntime.png) | ||
**Version 0.1.0** | ||
* Added exception if changed method doesn't exist in the class | ||
* Fixed reverting to default method implementation, not previous implementation | ||
* Fixed changing class and instance method with the same name | ||
* Fixed setting empty implementations | ||
* Converted to ARC |