Skip to content

Instantly share code, notes, and snippets.

@saiday
Last active September 17, 2015 15:28
Show Gist options
  • Select an option

  • Save saiday/c2cbd112c7f0b646f6de to your computer and use it in GitHub Desktop.

Select an option

Save saiday/c2cbd112c7f0b646f6de to your computer and use it in GitHub Desktop.
@interface KVOObjectTests : XCTestCase
@property (nonatomic) KVOObject *kVOObject;
@property (nonatomic) BOOL beenDealloc;
@property (nonatomic) id<AspectToken> aspectToken;
@end
- (void)setUp {
[super setUp];
self.kVOObject = [[KVOObject alloc] init];
@weakify(self);
self.aspectToken = [KVOObject
aspect_hookSelector:NSSelectorFromString(@"dealloc")
withOptions:AspectPositionBefore usingBlock:^(id<AspectInfo> aspectInfo){
@strongify(self);
self.beenDealloc = YES;
} error: nil];
}
- (void)tearDown {
self.kVOObject = nil;
assertThatBool(self.beenDealloc, isTrue());
[self.aspectToken remove];
[super tearDown];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment