-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathELCAsset.m
74 lines (65 loc) · 1.53 KB
/
ELCAsset.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
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
//
// Asset.m
//
// Created by ELC on 2/15/11.
// Copyright 2011 ELC Technologies. All rights reserved.
//
#import "ELCAsset.h"
#import "ELCAssetTablePicker.h"
@implementation ELCAsset
//Using auto synthesizers
- (NSString *)description
{
return [NSString stringWithFormat:@"ELCAsset index:%d",self.index];
}
- (id)initWithAsset:(ALAsset*)asset
{
self = [super init];
if (self) {
self.asset = asset;
_selected = NO;
}
return self;
}
- (void)toggleSelection
{
self.selected = !self.selected;
}
- (void)setSelected:(BOOL)selected
{
if (selected) {
if ([_parent respondsToSelector:@selector(shouldSelectAsset:)]) {
if (![_parent shouldSelectAsset:self]) {
return;
}
}
} else {
if ([_parent respondsToSelector:@selector(shouldDeselectAsset:)]) {
if (![_parent shouldDeselectAsset:self]) {
return;
}
}
}
_selected = selected;
if (selected) {
if (_parent != nil && [_parent respondsToSelector:@selector(assetSelected:)]) {
[_parent assetSelected:self];
}
} else {
if (_parent != nil && [_parent respondsToSelector:@selector(assetDeselected:)]) {
[_parent assetDeselected:self];
}
}
}
- (NSComparisonResult)compareWithIndex:(ELCAsset *)_ass
{
if (self.index > _ass.index) {
return NSOrderedDescending;
}
else if (self.index < _ass.index)
{
return NSOrderedAscending;
}
return NSOrderedSame;
}
@end