Skip to content

is FastEasyMapping ready for swift 4? #116

Description

@surkis

I have iOS project with swift 3.x, and trying to migrate it to latest swift 4.x
I have setuped FastEasyMapping via Cocoapods like this:
pod 'FastEasyMapping', :git => 'https://github.com/Yalantis/FastEasyMapping.git', :branch => 'required-pk'

But I have next crash issue when try to serialize/deserialize objects:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<fasteasymappingtest.SGSignInEntity 0x604000151b40> valueForUndefinedKey:]: this class is not key value coding-compliant for the key email.' *** First throw call stack: ( 0 CoreFoundation 0x000000010e6dc1e6 __exceptionPreprocess + 294 1 libobjc.A.dylib 0x000000010afb1031 objc_exception_throw + 48 2 CoreFoundation 0x000000010e6dc0b9 -[NSException raise] + 9 3 Foundation 0x000000010aa9ef58 -[NSObject(NSKeyValueCoding) valueForUndefinedKey:] + 226 4 Foundation 0x000000010a9caebc -[NSObject(NSKeyValueCoding) valueForKey:] + 284 5 FastEasyMapping 0x00000001098533fc -[FEMSerializer setValueOnRepresentation:fromObject:withFieldMapping:] + 156 6 FastEasyMapping 0x000000010985295f -[FEMSerializer _serializeObject:usingMapping:] + 463 7 FastEasyMapping 0x0000000109852c92 -[FEMSerializer serializeObject:usingMapping:] + 114 8 FastEasyMapping 0x0000000109853fe0 +[FEMSerializer(Shortcut) serializeObject:usingMapping:] + 144

In this method:
- (void)setValueOnRepresentation:(NSMutableDictionary *)representation fromObject:(id)object withFieldMapping:(FEMAttribute *)fieldMapping { id returnedValue = [object valueForKey:fieldMapping.property]; if (returnedValue || self.includeNulls) { returnedValue = [fieldMapping reverseMapValue:returnedValue] ?: [NSNull null]; [self setValue:returnedValue forKeyPath:fieldMapping.keyPath inRepresentation:representation]; } }

object can not return valueForKey, because doesn't casted to valid class.
I think it's some changes in Swift 4 and Objective-C relation.

Please provide any advise how to fix it? I am using your library in many places, and can not rewrite it to other libraries easy.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions