Menu

[4a5ff5]: / PlayerPRO Player / PPMusicListDragClass.m  Maximize  Restore  History

Download this file

76 lines (62 with data), 1.6 kB

 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//
// PPMusicListDragClass.m
// PPMacho
//
// Created by C.W. Betts on 12/8/13.
//
//
#import "PPMusicListDragClass.h"
#import "UserDefaultKeys.h"
@interface PPMusicListDragClass ()
@property (readwrite, copy) NSIndexSet *theIndexSet;
@end
@implementation PPMusicListDragClass
- (instancetype)initWithIndexSet:(NSIndexSet*)theSet
{
if (self = [super init]) {
self.theIndexSet = theSet;
}
return self;
}
+ (instancetype)dragWithIndexSet:(NSIndexSet*)theSet
{
return [[[self class] alloc] initWithIndexSet:theSet];
}
+ (NSPasteboardReadingOptions)readingOptionsForType:(NSString *)type pasteboard:(NSPasteboard *)pasteboard
{
if ([type isEqualToString:PPMLDCUTI])
return NSPasteboardReadingAsKeyedArchive;
else
return NSPasteboardReadingAsData;
}
static NSArray *UTIArray;
static dispatch_once_t dragOnceToken;
static const dispatch_block_t initUTIArray = ^{
UTIArray = @[PPMLDCUTI];
};
+ (NSArray *)readableTypesForPasteboard:(NSPasteboard *)pasteboard
{
dispatch_once(&dragOnceToken, initUTIArray);
return UTIArray;
}
- (NSArray *)writableTypesForPasteboard:(NSPasteboard *)pasteboard
{
dispatch_once(&dragOnceToken, initUTIArray);
return UTIArray;
}
- (id)pasteboardPropertyListForType:(NSString *)type
{
if ([type isEqualToString:PPMLDCUTI])
return [NSKeyedArchiver archivedDataWithRootObject:self];
else
return nil;
}
- (void)encodeWithCoder:(NSCoder *)aCoder
{
[aCoder encodeObject:_theIndexSet forKey:PPMLDCUTI];
}
- (id)initWithCoder:(NSCoder *)aDecoder
{
return self = [self initWithIndexSet:[aDecoder decodeObjectForKey:PPMLDCUTI]];
}
@end