forked from gnachman/iTerm2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandUse.m
More file actions
40 lines (33 loc) · 960 Bytes
/
CommandUse.m
File metadata and controls
40 lines (33 loc) · 960 Bytes
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
//
// CommandUse.m
// iTerm
//
// Created by George Nachman on 1/19/14.
//
//
#import "CommandUse.h"
@implementation CommandUse
- (void)dealloc {
[_mark release];
[_directory release];
[super dealloc];
}
- (NSArray *)serializedValue {
return @[ @(self.time), _directory ?: @"" ];
}
- (id)copyWithZone:(NSZone *)zone {
return [[[self class] commandUseFromSerializedValue:[self serializedValue]] retain];
}
+ (instancetype)commandUseFromSerializedValue:(id)serializedValue {
CommandUse *commandUse = [[[CommandUse alloc] init] autorelease];
if ([serializedValue isKindOfClass:[NSArray class]]) {
commandUse.time = [serializedValue[0] doubleValue];
if ([serializedValue count] > 1) {
commandUse.directory = serializedValue[1];
}
} else if ([serializedValue isKindOfClass:[NSNumber class]]) {
commandUse.time = [serializedValue doubleValue];
}
return commandUse;
}
@end