From 68467f87391b1887de90d60b0ebf03c0405430f6 Mon Sep 17 00:00:00 2001 From: Andrew Madsen Date: Wed, 4 Nov 2015 15:23:44 -0700 Subject: [PATCH] Issue #109: Fixed exception thrown when connecting to second (and subsequent) endpoints in MIKMIDIInputPort. --- Source/MIKMIDIInputPort.m | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Source/MIKMIDIInputPort.m b/Source/MIKMIDIInputPort.m index 04997613..7579dfb2 100644 --- a/Source/MIKMIDIInputPort.m +++ b/Source/MIKMIDIInputPort.m @@ -82,7 +82,7 @@ - (id)connectToSource:(MIKMIDISourceEndpoint *)source ![self connectToSource:source error:error]) { return nil; } - + NSString *uuidString = [self createNewConnectionToken]; [self addConnectionToken:uuidString andEventHandler:eventHandler forSource:source]; return uuidString; @@ -134,10 +134,12 @@ - (NSString *)createNewConnectionToken do { // Very unlikely, but just to be safe uuidString = [[NSUUID UUID] UUIDString]; MIKMIDIConnectionTokenAndEventHandler *existingPair = nil; - for (MIKMIDIConnectionTokenAndEventHandler *pair in self.handlerTokenPairsByEndpoint.objectEnumerator) { - if ([pair.connectionToken isEqualToString:uuidString]) { - existingPair = pair; - break; + for (NSArray *handlerPairs in self.handlerTokenPairsByEndpoint.objectEnumerator) { + for (MIKMIDIConnectionTokenAndEventHandler *pair in handlerPairs) { + if ([pair.connectionToken isEqualToString:uuidString]) { + existingPair = pair; + break; + } } } if (!existingPair) break;