1

Is there any way in mantle to convert a JSON data to MTLModelObject directly, I have gone through the documentation and haven't found a simple way to do so.

It seems there is only support for converting NSDictionary to MTLModelObjects and vice versa.

Vertexwahn
  • 7,709
  • 6
  • 64
  • 90
Ankur Teotia
  • 227
  • 1
  • 10
  • why cant you first parse your data to `NSDictionary` then convert it .. – vaibhav Sep 02 '16 at 09:44
  • 1
    I can do it, i am just wondering if there is a direct method to do it via mantle, it seems weird, also i have to convert it while rendering cells inside cellForRowAtIndexPath so i want a more optimised way to it if possible. – Ankur Teotia Sep 02 '16 at 09:56
  • Can you post an example of the JSON string you're working with? – David Snabel-Caunt Sep 02 '16 at 12:41
  • It can be any JSON string, i don't want to convert the JSON string to dictionary and then to my model object. – Ankur Teotia Sep 02 '16 at 12:57

1 Answers1

0

Mantle can not convert JSON string to model automatically. Override JSONTransformerForKey method and implement ur own NSValueTransformer by using NSJSONSerialization convert JSON String to NSDictionary