From 46ea7aacac02bbad81a5c0efd3d8233f9b87ec0a Mon Sep 17 00:00:00 2001 From: Jud Stephenson Date: Wed, 16 Jul 2014 13:16:33 -0400 Subject: [PATCH 1/2] Adding an isEqual Method When `TKStateMachine` tries to determine if it can fire an event, it does: ``` [tkEventInstance.states containsObject: self.currentState]; ``` If you haven't instantiated the current state with the exact `TKState` instance used when setting up the machine, this will always fail to fire events. This fixes that issue. --- Code/TKState.m | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Code/TKState.m b/Code/TKState.m index 1566339..6f16e7c 100644 --- a/Code/TKState.m +++ b/Code/TKState.m @@ -74,4 +74,20 @@ - (void)encodeWithCoder:(NSCoder *)aCoder [aCoder encodeObject:self.name forKey:@"name"]; } +# pragma mark - isEqual +- (BOOL)isEqual:(id)other +{ + if (other == self) { + return YES; + } + if (!other || ![other isKindOfClass:[self class]]) { + return NO; + } + if ([self name] != [other name]) { + return NO; + } + + return YES; +} + @end From 08d3f77197797fbc4c5e0f069f2804d2ab83d562 Mon Sep 17 00:00:00 2001 From: Jud Stephenson Date: Thu, 17 Jul 2014 10:34:40 -0400 Subject: [PATCH 2/2] Fixing incorrect comparison --- Code/TKState.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/TKState.m b/Code/TKState.m index 6f16e7c..99047c5 100644 --- a/Code/TKState.m +++ b/Code/TKState.m @@ -83,7 +83,7 @@ - (BOOL)isEqual:(id)other if (!other || ![other isKindOfClass:[self class]]) { return NO; } - if ([self name] != [other name]) { + if (![[self name] isEqualToString: [other name]]) { return NO; }