summaryrefslogtreecommitdiffstats
path: root/macosx/HBSecurityAccessToken.m
blob: 027f66920bf588a861768f225004111ddbd86624 (plain)
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
//
//  HBSecurityAccessToken.m
//  HandBrake
//
//  Created by Damiano Galassi on 24/01/17.
//
//

#import "HBSecurityAccessToken.h"

@interface HBSecurityAccessToken ()
@property (nonatomic, readonly) id<HBSecurityScope> object;
@property (nonatomic, readonly) BOOL accessed;
@end

@implementation HBSecurityAccessToken

- (instancetype)initWithObject:(id<HBSecurityScope>)object;
{
    self = [super init];
    if (self)
    {
        _object = object;
        _accessed = [_object startAccessingSecurityScopedResource];
    }
    return self;
}

+ (instancetype)tokenWithObject:(id<HBSecurityScope>)object
{
    return [[self alloc] initWithObject:object];
}

- (void)dealloc
{
    if (_accessed)
    {
        [_object stopAccessingSecurityScopedResource];
    }
}

@end