I have a problem when I get invalid exceptions, but only when the test assembly is complete (calling the same methods in the debug assembly does not cause a problem). ARC is included in the project, and I run it on the iPad 5.1 simulator using Xcode 4.3:
This is where the problem arises:
- (void)testChangeFoodNotification { Player* p = [[Player alloc] init]; [p addObserver:self forKeyPath:@"food" options:0 context:0];
At the time the addObserver: method is addObserver: , does not it appear that any of the objects involved were to be released, so what could throw an exception?
EDIT:
Sorry if this wasnβt clear, but the above code runs as part of a test case (using the standard Xcode OCUnit). Also, if he clarifies something here, the corresponding code from the player's class (there are other ivars and methods, but they have nothing to do with the property or methods being tested):
// Public interface @interface Player : NSObject @property (nonatomic, assign) NSInteger food; @end // Private interface @interface Player() { NSInteger _food; } @end @implementation Player @synthesize food = _food;
Mattia
source share