-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
is FastEasyMapping ready for swift 4? #116
Comments
Attached archive of test project, so you can test problem yourself: When I changed to swift 3.3, in target Build settings, all working as expected. |
@surkis thank you so much for provided feedback. I would assume, that this is because in Swift 4 behaviour of swift-objc interoperability has been changed. Therefore subclassing from |
@dimazen thank you for such fast feedback. Thank you for your help. I will continue with migration in my project tomorrow, and if I will find something new, will contact with you. |
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.
The text was updated successfully, but these errors were encountered: