-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSWXMLMemberMapping.m
More file actions
45 lines (32 loc) · 1.22 KB
/
SWXMLMemberMapping.m
File metadata and controls
45 lines (32 loc) · 1.22 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
//
// SWXMLMemberMapping.m
// This file is part of the "SWXMLMapping" project, and is distributed under the MIT License.
//
// Created by Samuel Williams on 13/11/05.
// Copyright 2005 Samuel Williams. All rights reserved.
//
#import "SWXMLMemberMapping.h"
#import "SWXMLClassMapping.h"
@implementation SWXMLMemberMapping
@synthesize tag = _tag, keyPath = _keyPath, attributes = _attributes;
- (instancetype)initWithTag:(NSString *)tag keyPath:(NSString *)keyPath attributes:(NSAttributeDictionary *)attributes {
self = [super init];
if (self) {
self.tag = tag;
self.keyPath = keyPath;
self.attributes = attributes;
self.objectClassName = [attributes valueForKey:@"class"];
}
return self;
}
- (instancetype) initWithAttributes: (NSDictionary*)attributes {
return [self initWithTag:[attributes valueForKey:@"tag"] keyPath:[attributes valueForKey:@"keyPath"] attributes:attributes];
}
- (NSString*) serializedObjectMember:(id) object withMapping:(SWXMLMapping*)mapping {
SWXMLClassMapping * classMapping = nil;
if (self.objectClassName) {
classMapping = (mapping.objectMappings)[self.objectClassName];
}
return [mapping serializeObject:[object valueForKeyPath:self.keyPath] withClassMapping:classMapping];
}
@end