forked from arqbackup/arq_restore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserAndComputer.m
62 lines (59 loc) · 1.65 KB
/
UserAndComputer.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
//
// UserAndComputer.m
// Arq
//
// Created by Stefan Reitshamer on 7/9/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import "UserAndComputer.h"
#import "Computer.h"
#import "DictNode.h"
@implementation UserAndComputer
- (id)init {
if (self = [super init]) {
userName = [NSUserName() copy];
computerName = [[Computer name] copy];
}
return self;
}
- (id)initWithXMLData:(NSData *)theXMLData error:(NSError **)error {
if (self = [super init]) {
DictNode *plist = [DictNode dictNodeWithXMLData:theXMLData error:error];
if (plist == nil) {
[self release];
return nil;
}
userName = [[[plist stringNodeForKey:@"userName"] stringValue] copy];
computerName = [[[plist stringNodeForKey:@"computerName"] stringValue] copy];
}
return self;
}
- (id)initWithUserName:(NSString *)theUserName computerName:(NSString *)theComputerName {
if (self = [super init]) {
userName = [theUserName retain];
computerName = [theComputerName retain];
}
return self;
}
- (void)dealloc {
[userName release];
[computerName release];
[super dealloc];
}
- (NSString *)userName {
return userName;
}
- (NSString *)computerName {
return computerName;
}
- (NSData *)toXMLData {
DictNode *plist = [[[DictNode alloc] init] autorelease];
[plist putString:userName forKey:@"userName"];
[plist putString:computerName forKey:@"computerName"];
return [plist XMLData];
}
#pragma mark NSObject
- (NSString *)description {
return [NSString stringWithFormat:@"<UserAndComputer: userName=%@ computerName=%@>", userName, computerName];
}
@end