Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
steipete committed May 4, 2014
1 parent d3af104 commit 76f1aac
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,22 @@ You can check if methods are really being called in your test cases:
__block BOOL testCallCalled = NO;
[testClass aspect_hookSelector:@selector(testCall) atPosition:AspectPositionAfter withBlock:^(id object, NSArray *arguments) {
testCallCalled = YES;
}];
} error:NULL];
[testClass2 testCallAndExecuteBlock:^{
[testClass testCall];
}];
} error:NULL];
XCTAssertTrue(testCallCalled, @"Calling testCallAndExecuteBlock must call testCall");
}
```
-------------------
It can be really useful for debugging. Here I was curious when exactly the tap gesture changed state:

``` objc
[_singleTapGesture aspect_hookSelector:@selector(setState:) atPosition:AspectPositionAfter withBlock:^(__unsafe_unretained id object, NSArray *arguments) {
NSLog(@"%@: %@", object, arguments);
} error:NULL];
```
-------------------
Another convenient use case is adding handlers for classes that you don't own. I've written it for use in [PSPDFKit](http://pspdfkit.com), where we require notifications when a view controller is being dismissed modally. This includes UIKit view controllers like `MFMailComposeViewController` or `UIImagePickerController`. We could have created subclasses for each of these controllers, but this would be quite a lot of unnecessary code. Aspects gives you a simpler solution for this problem:
Expand All @@ -83,7 +91,7 @@ Another convenient use case is adding handlers for classes that you don't own. I
if (weakSelf.isBeingDismissed) {
action();
}
}];
} error:NULL];
}
@end
Expand Down Expand Up @@ -112,7 +120,7 @@ When you're using Aspects with `AspectPositionInstead`, the last argument of the
processTouches = pspdf_stylusShouldProcessTouches(arguments[0], arguments[1]);
[invocation setReturnValue:&processTouches];
}
}];
} error:NULL];
```
Installation
Expand Down

0 comments on commit 76f1aac

Please sign in to comment.