OLD | NEW |
1 //------------------------------------------------------------------------------
--------- | 1 //------------------------------------------------------------------------------
--------- |
2 // $Id: OCObserverMockObject.m 57 2010-07-19 06:14:27Z erik $ | 2 // $Id$ |
3 // Copyright (c) 2009 by Mulle Kybernetik. See License file for details. | 3 // Copyright (c) 2009 by Mulle Kybernetik. See License file for details. |
4 //------------------------------------------------------------------------------
--------- | 4 //------------------------------------------------------------------------------
--------- |
5 | 5 |
6 #import "OCObserverMockObject.h" | 6 #import "OCObserverMockObject.h" |
7 #import "OCMObserverRecorder.h" | 7 #import "OCMObserverRecorder.h" |
8 | 8 |
9 | 9 |
10 @implementation OCObserverMockObject | 10 @implementation OCObserverMockObject |
11 | 11 |
12 #pragma mark Initialisers, description, accessors, etc. | 12 #pragma mark Initialisers, description, accessors, etc. |
13 | 13 |
14 - (id)init | 14 - (id)init |
15 { | 15 { |
16 » [super init]; | 16 » self = [super init]; |
17 recorders = [[NSMutableArray alloc] init]; | 17 recorders = [[NSMutableArray alloc] init]; |
18 return self; | 18 return self; |
19 } | 19 } |
20 | 20 |
21 - (void)dealloc | 21 - (void)dealloc |
22 { | 22 { |
23 [recorders release]; | 23 [recorders release]; |
24 [super dealloc]; | 24 [super dealloc]; |
25 } | 25 } |
26 | 26 |
(...skipping 30 matching lines...) Expand all Loading... |
57 [self description], [recorders count]]; | 57 [self description], [recorders count]]; |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 | 61 |
62 | 62 |
63 #pragma mark Receiving notifications | 63 #pragma mark Receiving notifications |
64 | 64 |
65 - (void)handleNotification:(NSNotification *)aNotification | 65 - (void)handleNotification:(NSNotification *)aNotification |
66 { | 66 { |
67 » int i, limit; | 67 » NSUInteger i, limit; |
68 | 68 |
69 limit = expectationOrderMatters ? 1 : [recorders count]; | 69 limit = expectationOrderMatters ? 1 : [recorders count]; |
70 for(i = 0; i < limit; i++) | 70 for(i = 0; i < limit; i++) |
71 { | 71 { |
72 if([[recorders objectAtIndex:i] matchesNotification:aNotificatio
n]) | 72 if([[recorders objectAtIndex:i] matchesNotification:aNotificatio
n]) |
73 { | 73 { |
74 [recorders removeObjectAtIndex:i]; | 74 [recorders removeObjectAtIndex:i]; |
75 return; | 75 return; |
76 } | 76 } |
77 } | 77 } |
78 [NSException raise:NSInternalInconsistencyException format:@"%@: unexpec
ted notification observed: %@", [self description], | 78 [NSException raise:NSInternalInconsistencyException format:@"%@: unexpec
ted notification observed: %@", [self description], |
79 [aNotification description]]; | 79 [aNotification description]]; |
80 } | 80 } |
81 | 81 |
82 | 82 |
83 @end | 83 @end |
OLD | NEW |