Skip to content

Instantly share code, notes, and snippets.

@loentar
Created April 14, 2017 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loentar/1e2d1aa0f9155f602db2a07d99e44b00 to your computer and use it in GitHub Desktop.
Save loentar/1e2d1aa0f9155f602db2a07d99e44b00 to your computer and use it in GitHub Desktop.
evobject_workaround_swift_crash.patch
diff -u Source-latest/EVObject.swift Source-patched/EVObject.swift
--- Source-latest/EVObject.swift 2017-04-13 17:35:35.000000000 +0300
+++ Source-patched/EVObject.swift 2017-04-14 11:38:41.000000000 +0300
@@ -121,7 +121,7 @@
- returns: Return an array with value pairs of the object property name and json key name.
*/
- open func propertyMapping() -> [(keyInObject: String?, keyInResource: String?)] {
+ open func propertyMapping() -> Any /*[(keyInObject: String?, keyInResource: String?)]*/ {
return []
}
diff -u Source-latest/EVReflectable.swift Source-patched/EVReflectable.swift
--- Source-latest/EVReflectable.swift 2017-04-13 17:35:35.000000000 +0300
+++ Source-patched/EVReflectable.swift 2017-04-14 11:41:07.000000000 +0300
@@ -30,7 +30,7 @@
- returns: Return an array with value pairs of the object property name and json key name.
*/
- func propertyMapping() -> [(keyInObject: String?, keyInResource: String?)]
+ func propertyMapping() -> Any //[(keyInObject: String?, keyInResource: String?)]
/**
Override this method when you want custom property value conversion
@@ -282,7 +282,7 @@
- returns: Return an array with value pairs of the object property name and json key name.
*/
- public func propertyMapping() -> [(keyInObject: String?, keyInResource: String?)] {
+ public func propertyMapping() -> Any /*[(keyInObject: String?, keyInResource: String?)]*/ {
return []
}
diff -u Source-latest/EVReflection.swift Source-patched/EVReflection.swift
--- Source-latest/EVReflection.swift 2017-04-13 17:35:35.000000000 +0300
+++ Source-patched/EVReflection.swift 2017-04-14 11:42:24.000000000 +0300
@@ -67,7 +67,7 @@
var skipKey = false
if conversionOptions.contains(.PropertyMapping) {
if let reflectable = anyObject as? EVReflectable {
- if let mapping = reflectable.propertyMapping().filter({$0.keyInObject == k as? String}).first {
+ if let mapping = (reflectable.propertyMapping() as! [(keyInObject: String?, keyInResource: String?)]).filter({$0.keyInObject == k as? String}).first {
if mapping.1 == nil {
skipKey = true
}
@@ -116,7 +116,7 @@
for (objectKey, _) in properties {
if conversionOptions.contains(.PropertyMapping) {
if let reflectable = anyObject as? EVReflectable {
- if let mapping = reflectable.propertyMapping().filter({$0.keyInResource == objectKey as? String}).first {
+ if let mapping = (reflectable.propertyMapping() as! [(keyInObject: String?, keyInResource: String?)]).filter({$0.keyInResource == objectKey as? String}).first {
keyMapping[objectKey as? String ?? ""] = mapping.keyInObject
}
}
@@ -1307,7 +1307,7 @@
}
if conversionOptions.contains(.PropertyMapping) {
if let reflectable = theObject as? EVReflectable {
- if let mapping = reflectable.propertyMapping().filter({$0.keyInObject == originalKey}).first {
+ if let mapping = (reflectable.propertyMapping() as! [(keyInObject: String?, keyInResource: String?)]).filter({$0.keyInObject == originalKey}).first {
if mapping.1 == nil {
skipThisKey = true
} else {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment