Closed itruf closed 4 years ago
@tristanhimmelman I'm not pretty sure about library architecture. Hope that you will find some time to check my PR.
@tristanhimmelman it's a critical problem with ImmutableMappable. Please check it out.
@tristanhimmelman I'm really sorry for pushing you but it's the very important PR for the project. I hope that you will take a look at it.
Thank you @tristanhimmelman
this update caused many crashes in my app where I init an ImmutableMappable from a json string and from a json dict, both now cause runtime crash.
@murad1981 can you show an example of your model and a JSON string caused crash? I think that it's correct behavior if you init an ImmutableMappable model with an incorrect JSON.
I've started research to fix warning mentioned here: https://github.com/tristanhimmelman/ObjectMapper/issues/1043#issuecomment-479406127
If you try to init ImmutableMappable with JSONString - swift shows warning that this method has no calls to throwing functions.
I found that:
ImmutableMappable
inherits fromBaseMappable
ImmutableMappable
has an extension with init methods which throws (likeinit(JSONString: String, context: MapContext? = nil) throws
)BaseMappable
has an extension with optional init methods (likeinit?(JSONString: String, context: MapContext? = nil)
)It causes crashes in some cases.
For example:
let response = try? MyModel(JSONString: jsonString)
will crash ifMyModel
is ImmutableMappable and throws in init method.I'm not sure but it can be caused by selecting optional init from
BaseMappable
which not marked withthrows
.