Skip to content

Commit

Permalink
➕Add valueTransformerName to attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
e-marchand committed Nov 13, 2019
1 parent 46bcaea commit af19240
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 16 deletions.
26 changes: 11 additions & 15 deletions MomXML.xcodeproj/xcshareddata/xcschemes/MomXML.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,17 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
codeCoverageEnabled = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "484F8E4B1EE81D8800C854AA"
BuildableName = "MomXML.framework"
BlueprintName = "MomXML"
ReferencedContainer = "container:MomXML.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -40,17 +49,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "484F8E4B1EE81D8800C854AA"
BuildableName = "MomXML.framework"
BlueprintName = "MomXML"
ReferencedContainer = "container:MomXML.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -71,8 +69,6 @@
ReferencedContainer = "container:MomXML.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
2 changes: 1 addition & 1 deletion Sources/FromCoreData/NSAttributeDescription+MomXML.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extension NSAttributeDescription {
mom.isIndexed = self.isIndexed
}
mom.isIndexedBySpotlight = self.isIndexedBySpotlight

mom.valueTransformerName = self.valueTransformerName
return mom
}

Expand Down
1 change: 1 addition & 0 deletions Sources/FromXML/MomAttribute+XMLObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ extension MomAttribute: XMLObject {
self.minValueString = element.attribute(by: "minValueString")?.text
self.maxValueString = element.attribute(by: "maxValueString")?.text
self.derivationExpression = element.attribute(by: "derivationExpression")?.text
self.valueTransformerName = element.attribute(by: "valueTransformerName")?.text

for xml in xml.children {
if let object = MomUserInfo(xml: xml) {
Expand Down
1 change: 1 addition & 0 deletions Sources/Model/MomAttribute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public struct MomAttribute {
public var isIndexedBySpotlight: Bool = false
public var isDerived: Bool = false
public var derivationExpression: String?
public var valueTransformerName: String?

public var userInfo = MomUserInfo()

Expand Down
1 change: 1 addition & 0 deletions Sources/ToCoreData/MomAttribute+CoreData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ extension MomAttribute {
}
coreData.isIndexedBySpotlight = self.isIndexedBySpotlight
coreData.userInfo = self.userInfo.coreData
coreData.valueTransformerName = self.valueTransformerName

return coreData
}
Expand Down
4 changes: 4 additions & 0 deletions Sources/ToXML/MomAttribute+XMLConvertible.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ extension MomAttribute: XMLConvertible {

output += " syncable=\"\(syncable.xml)\""

if let valueTransformerName = valueTransformerName {
output += " valueTransformerName=\"\(valueTransformerName)\""
}

if self.userInfo.isEmpty {
output += "/>"
} else {
Expand Down
6 changes: 6 additions & 0 deletions Tests/modelJsonToXML.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
<attribute name="attribut1" attributeType="String" optional="NO" indexed="YES" syncable="YES"/>
<attribute name="attribut3" attributeType="Integer 16" optional="NO" usesScalarValueType="YES" indexed="YES" syncable="YES"/>
<attribute name="attribut2" attributeType="String" optional="NO" indexed="YES" syncable="YES"/>
<attribute attributeType="Transformable" indexed="NO" name="picture" optional="YES" syncable="YES" valueTransformerName="NSSecureUnarchiveFromData">
<userInfo>
<entry key="keyMapping" value="Picture field"/>
<entry key="image" value="YES"/>
</userInfo>
</attribute>
</entity>
<elements>
<element name="Produit" positionX="0" positionY="0" width="128" height="230"/>
Expand Down

0 comments on commit af19240

Please sign in to comment.