forked from flit/MidiKeys
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EndpointDefaults.m
46 lines (37 loc) · 1017 Bytes
/
EndpointDefaults.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//
// EndpointDefaults.m
// MidiKeys
//
// Created by Chris Reed on Wed Oct 23 2002.
// Copyright (c) 2002 Chris Reed. All rights reserved.
//
#import "EndpointDefaults.h"
@implementation NSUserDefaults (EndpointDefaults)
- (MIDIEndpointRef)endpointForKey:(NSString *)key
{
MIDIUniqueID endpointUID = [self integerForKey:key];
if (endpointUID != 0)
{
MIDIObjectType objType;
MIDIObjectRef obj;
OSStatus err = MIDIObjectFindByUniqueID(endpointUID, &obj, &objType);
if (err == noErr && (objType == kMIDIObjectType_Destination
|| objType == kMIDIObjectType_ExternalDestination
|| objType == kMIDIObjectType_Source
|| objType == kMIDIObjectType_ExternalSource))
{
return (MIDIEndpointRef)obj;
}
}
return 0;
}
- (void)setEndpoint:(MIDIEndpointRef)endpoint forKey:(NSString *)key
{
MIDIUniqueID endpointUID;
OSStatus err = MIDIObjectGetIntegerProperty(endpoint, kMIDIPropertyUniqueID, &endpointUID);
if (err == noErr)
{
[self setInteger:endpointUID forKey:key];
}
}
@end