Skip to content

Commit c17eea0

Browse files
committed
Adds support for Hearst-DD/ObjectMapper
1 parent 5c93c29 commit c17eea0

File tree

7 files changed

+221
-47
lines changed

7 files changed

+221
-47
lines changed

SwiftyJSONAccelerator.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
93F1744A1BD0707D007E7DFC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 93F174481BD0707D007E7DFC /* Main.storyboard */; };
2121
93F174551BD0707D007E7DFC /* SwiftyJSONAcceleratorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93F174541BD0707D007E7DFC /* SwiftyJSONAcceleratorTests.swift */; };
2222
93F174601BD070AA007E7DFC /* JSONHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93F1745F1BD070AA007E7DFC /* JSONHelper.swift */; };
23+
C667011B1BDCABCE009BA254 /* SwiftyJSONTemplate.txt in Resources */ = {isa = PBXBuildFile; fileRef = C667011A1BDCABCE009BA254 /* SwiftyJSONTemplate.txt */; };
24+
C667011D1BDCAF23009BA254 /* ObjectMapperTemplate.txt in Resources */ = {isa = PBXBuildFile; fileRef = C667011C1BDCAF23009BA254 /* ObjectMapperTemplate.txt */; };
2325
/* End PBXBuildFile section */
2426

2527
/* Begin PBXContainerItemProxy section */
@@ -49,6 +51,8 @@
4951
93F174541BD0707D007E7DFC /* SwiftyJSONAcceleratorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftyJSONAcceleratorTests.swift; sourceTree = "<group>"; };
5052
93F174561BD0707D007E7DFC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
5153
93F1745F1BD070AA007E7DFC /* JSONHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSONHelper.swift; sourceTree = "<group>"; };
54+
C667011A1BDCABCE009BA254 /* SwiftyJSONTemplate.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SwiftyJSONTemplate.txt; sourceTree = "<group>"; };
55+
C667011C1BDCAF23009BA254 /* ObjectMapperTemplate.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ObjectMapperTemplate.txt; sourceTree = "<group>"; };
5256
/* End PBXFileReference section */
5357

5458
/* Begin PBXFrameworksBuildPhase section */
@@ -73,6 +77,8 @@
7377
isa = PBXGroup;
7478
children = (
7579
9341A14E1BD6E7290048CE2C /* BaseTemplate.txt */,
80+
C667011A1BDCABCE009BA254 /* SwiftyJSONTemplate.txt */,
81+
C667011C1BDCAF23009BA254 /* ObjectMapperTemplate.txt */,
7682
);
7783
path = "Base Files";
7884
sourceTree = "<group>";
@@ -228,7 +234,9 @@
228234
isa = PBXResourcesBuildPhase;
229235
buildActionMask = 2147483647;
230236
files = (
237+
C667011B1BDCABCE009BA254 /* SwiftyJSONTemplate.txt in Resources */,
231238
93F174471BD0707D007E7DFC /* Assets.xcassets in Resources */,
239+
C667011D1BDCAF23009BA254 /* ObjectMapperTemplate.txt in Resources */,
232240
9341A14F1BD6E7290048CE2C /* BaseTemplate.txt in Resources */,
233241
93F1744A1BD0707D007E7DFC /* Main.storyboard in Resources */,
234242
);

SwiftyJSONAccelerator/Base Files/BaseTemplate.txt

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
// Copyright (c) __MyCompanyName__. All rights reserved.
66
//
77

8-
import Foundation{INCLUDE_SWIFTY}
8+
import Foundation{INCLUDE_SWIFTY}{INCLUDE_OBJECT_MAPPER}
99

10-
public {OBJECT_KIND} {OBJECT_NAME}: NSObject, NSCoding {
10+
public {OBJECT_KIND} {OBJECT_NAME}: {OBJECT_BASE_CLASS}{NSCODING_PROTOCOL_SUPPORT} {
1111

1212
// MARK: Declaration for string constants to be used to decode and also serialize.
1313
{STRING_CONSTANT_BLOCK}
@@ -16,34 +16,20 @@ public {OBJECT_KIND} {OBJECT_NAME}: NSObject, NSCoding {
1616
{PROPERTIES}
1717

1818
// MARK: Initalizers
19-
/**
20-
Initates the class based on the object
21-
- parameter object: The object of either Dictionary or Array kind that was passed.
22-
- returns: An initalized instance of the class.
23-
*/
24-
convenience public init(object: AnyObject) {
25-
self.init(json: JSON(object))
26-
}
19+
{SWIFTY_JSON_SUPPORT}
2720

28-
/**
29-
Initates the class based on the JSON that was passed.
30-
- parameter json: JSON object from SwiftyJSON.
31-
- returns: An initalized instance of the class.
32-
*/
33-
public init(json: JSON) {
34-
{INITALIZER}
35-
}
21+
{OBJECT_MAPPER_SUPPORT}
3622

3723
/**
3824
Generates description of the object in the form of a NSDictionary.
3925
- returns: A Key value pair containing all valid values in the object.
4026
*/
4127
public func dictionaryRepresentation() -> [String : AnyObject ] {
4228

43-
var dictionary: [String : AnyObject ] = [ : ]
44-
{DESC}
29+
var dictionary: [String : AnyObject ] = [ : ]
30+
{DESC}
4531

46-
return dictionary
32+
return dictionary
4733
}
4834

4935
{NSCODING_SUPPORT}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
Map a JSON object to this class using ObjectMapper
3+
- parameter map: A mapping from ObjectMapper
4+
*/
5+
required init?(_ map: Map){
6+
7+
}
8+
9+
/**
10+
Map a JSON object to this class using ObjectMapper
11+
- parameter map: A mapping from ObjectMapper
12+
*/
13+
func mapping(map: Map) {
14+
{OBJECT_MAPPER_INITIALIZER}
15+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
Initates the class based on the object
3+
- parameter object: The object of either Dictionary or Array kind that was passed.
4+
- returns: An initalized instance of the class.
5+
*/
6+
convenience public init(object: AnyObject) {
7+
self.init(json: JSON(object))
8+
}
9+
10+
/**
11+
Initates the class based on the JSON that was passed.
12+
- parameter json: JSON object from SwiftyJSON.
13+
- returns: An initalized instance of the class.
14+
*/
15+
public init(json: JSON) {
16+
{INITALIZER}
17+
}

0 commit comments

Comments
 (0)