Skip to content

Instantly share code, notes, and snippets.

@yashigani
Created February 25, 2014 01:10
Show Gist options
  • Save yashigani/9200664 to your computer and use it in GitHub Desktop.
Save yashigani/9200664 to your computer and use it in GitHub Desktop.
//
// KVOSampleTests.m
// KVOSampleTests
//
// Created by taiki on 2014/02/25.
//
//
#import <XCTest/XCTest.h>
@interface KVOSampleTests : XCTestCase
@property (strong, nonatomic) UIView *observee;
@end
@implementation KVOSampleTests
- (void)setUp
{
[super setUp];
_observee = UIView.new;
}
- (void)tearDown
{
[super tearDown];
_observee = nil;
}
- (void)testAddObserverManyTimes
{
[_observee addObserver:self
forKeyPath:@"frame"
options:NSKeyValueObservingOptionOld
context:NULL];
[_observee addObserver:self
forKeyPath:@"frame"
options:NSKeyValueObservingOptionOld
context:NULL];
[_observee removeObserver:self forKeyPath:@"frame" context:NULL];
[_observee removeObserver:self forKeyPath:@"frame" context:NULL]; // 取るとobserverが残ってるって怒られる
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment