diff --git a/Framework/MIKMIDI.xcodeproj/project.pbxproj b/Framework/MIKMIDI.xcodeproj/project.pbxproj index 77505352..aa316fca 100644 --- a/Framework/MIKMIDI.xcodeproj/project.pbxproj +++ b/Framework/MIKMIDI.xcodeproj/project.pbxproj @@ -302,6 +302,7 @@ 9DF99E7A1831841A004EE5F4 /* MIKMIDICommandThrottler.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DF99E781831841A004EE5F4 /* MIKMIDICommandThrottler.m */; }; 9DF99E7D18318D44004EE5F4 /* MIKMIDIPrivateUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DF99E7B18318D44004EE5F4 /* MIKMIDIPrivateUtilities.h */; }; 9DF99E7E18318D44004EE5F4 /* MIKMIDIPrivateUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DF99E7C18318D44004EE5F4 /* MIKMIDIPrivateUtilities.m */; }; + D9E590031FA20E8600166B5C /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D9E590021FA20E8600166B5C /* UIKit.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -487,6 +488,7 @@ 9DF99E7B18318D44004EE5F4 /* MIKMIDIPrivateUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MIKMIDIPrivateUtilities.h; sourceTree = ""; }; 9DF99E7C18318D44004EE5F4 /* MIKMIDIPrivateUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MIKMIDIPrivateUtilities.m; sourceTree = ""; }; 9DFDC2B61820305C00C4C66D /* MIKMIDIPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MIKMIDIPrivate.h; sourceTree = ""; }; + D9E590021FA20E8600166B5C /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.0.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -512,6 +514,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + D9E590031FA20E8600166B5C /* UIKit.framework in Frameworks */, 9DAF8B8A1A7B028B00F46528 /* libxml2.dylib in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -599,6 +602,7 @@ 9D74EEA717A7129300BEE89F /* Frameworks */ = { isa = PBXGroup; children = ( + D9E590021FA20E8600166B5C /* UIKit.framework */, 9DAF8B861A7B01AA00F46528 /* libxml2.2.dylib */, 9DAF8B841A7B019900F46528 /* libxml2.dylib */, 9DE259E719A7B50600DA93E9 /* AudioToolbox.framework */, diff --git a/Source/MIKMIDIDeviceManager.m b/Source/MIKMIDIDeviceManager.m index 41ac3298..18504120 100644 --- a/Source/MIKMIDIDeviceManager.m +++ b/Source/MIKMIDIDeviceManager.m @@ -16,6 +16,10 @@ #import "MIKMIDIClientSourceEndpoint.h" #import "MIKMIDIErrors.h" +#if TARGET_OS_IPHONE +#import +#endif + #if !__has_feature(objc_arc) #error MIKMIDIDeviceManager.m must be compiled with ARC. Either turn on ARC for the project or set the -fobjc-arc flag for MIKMIDIDeviceManager.m in the Build Phases for this target #endif @@ -73,6 +77,12 @@ - (id)init [self createClient]; [self retrieveAvailableDevices]; [self retrieveVirtualEndpoints]; + +#if TARGET_OS_IPHONE + NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + [nc addObserver:self selector:@selector(appDidBecomeActiveNotification:) name:UIApplicationDidBecomeActiveNotification object:nil]; +#endif + } return self; } @@ -87,6 +97,11 @@ - (id)copyWithZone:(NSZone *)zone return self; } +- (void)dealloc +{ + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + #pragma mark - Public - (nullable id)connectDevice:(MIKMIDIDevice *)device error:(NSError **)error eventHandler:(MIKMIDIEventHandlerBlock)eventHandler @@ -184,6 +199,13 @@ - (void)retrieveVirtualEndpoints self.internalVirtualDestinations = destinations; } +#pragma mark - Notifications + +- (void)appDidBecomeActiveNotification:(NSNotification *)notification +{ + [self retrieveAvailableDevices]; +} + #pragma mark - Callbacks - (void)handleMIDIObjectPropertyChangeNotification:(MIDIObjectPropertyChangeNotification *)notification @@ -456,4 +478,4 @@ - (void)disconnectInput:(MIKMIDISourceEndpoint *)endpoint forConnectionToken:(id [self disconnectConnectionForToken:connectionToken]; } -@end \ No newline at end of file +@end