Questions tagged [github-mantle]

Model framework for Cocoa and Cocoa Touch by GitHub

Mantle is a model framework for Cocoa and Cocoa Touch created and maintained by Justin Spahr-Summers at GitHub.

Mantle allows developers to quickly and easily write a simple model layer for their applications by providing them such tools, as:

  • Automatic two-way JSON serialization
  • Automatic two-way NSManagedObject serialization
  • Exception handling
  • Versioning support

Resources:

Questions tagged under should be directly connected with Mantle. If your project is using Mantle but the question is not connectet with it, don't add this tag to yor question.

91 questions
5
votes
3 answers

Mantle convert 0 and 1 to BOOL automatically?

Does Mantle already converts int values 0 and 1 in JSON to objective-C BOOL values? I have a model: @interface MyModel : MTLModel @property (nonatomic, readonly) BOOL isValid; @end And lets say JSON is: { is_valid: 0 } OR { is_valid: 1 } I want…
nefarianblack
  • 802
  • 8
  • 16
5
votes
1 answer

Mantle:cannot find protocol declaration, 'MTLJSONSerializing'

I installed 'Mantle' using coco pod. But when I try to use it in my model, it is getting this error. /Users/bgbb/Developer/experimental/MantleTest/MantleTest/TestMTL.h:11:32: Cannot find protocol declaration for 'MTLJSONSerializing' #import…
Imju
  • 539
  • 5
  • 11
4
votes
1 answer

Mantle - Transform a Nested Model in Swift

I am having a lot of trouble de-serializing and serializing a nested model in Swift using Mantle. I believe I have everything set up correctly, but I can't even get past the compilation errors. To give some perspective, I have successfully…
Alexander
  • 3,959
  • 2
  • 31
  • 58
4
votes
1 answer

Xcode gives errors for specific words in a commented block of text

I'm using Mantle in my project to serialize objects. The library is used by many and I'm sure the errors are not related to them. When I include Mantle.h or specifically MTLJSONAdapter.h it gives some unrelated errors for a block of text that's…
akaralar
  • 1,103
  • 1
  • 10
  • 29
4
votes
1 answer

How to add a relationship to the parent with Mantle?

I have Parent/child class like this: @interface Parent : MTLModel - (void)someMethod; @property a,b,c...; // from the JSON @property NSArray *childs; // from the JSON @end @interface Child : MTLModel…
malaba
  • 599
  • 5
  • 22
4
votes
0 answers

Mantle Transform With Nested Dictionaries

I thought this question would work for my situation, but my lack of experience with Mantle and iOS in general has dead ended my train of thought. Basically, I have a big chunk of JSON with nested dictionaries and arrays that I want to convert into…
Nick Coelius
  • 4,668
  • 3
  • 24
  • 30
4
votes
1 answer

Transform NSString to NSURL within a JSON Array with Mantle

Let's say given to me is the following JSON response { "images": [ "http://domain.com/image1.jpg", "http://domain.com/image2.jpg", "http://domain.com/image3.jpg" ] } With Mantle I want to parse those strings and…
Martin Stolz
  • 5,176
  • 3
  • 21
  • 19
4
votes
2 answers

Encoding c-struct with Mantle (NSCoding)

I want to use Mantle framework (https://github.com/github/Mantle) to support NSCoding for my class with struct property: typedef struct { int x; int y; } MPoint; typedef struct { MPoint min; MPoint max; } MRect; @interface MObject…
podkovyr
  • 135
  • 3
  • 11
4
votes
1 answer

Trouble when returning non pointer object in a block

I'm using Mantle to help me transform model objects to JSON. One of my objects contains a centroid property defined as follows: @property (assign) CLLocationCoordinate2D centroid; When I deal with the server I receive the property in this…
3
votes
2 answers

Realm + Mantle: how to avoid multiple inheritance duplication when integrating both frameworks?

I have a simple scenario where I want to parse a User model from Json with Mantle and persist it to a realm database: In order to use the Mantle library, the model interface must extend the MTLModel class like this: @interface User:…
Mina Wissa
  • 10,923
  • 13
  • 90
  • 158
3
votes
1 answer

Mantle parsing array

I am using mantle framework to parse JSON file. My JSON object Looks like this [{ key:value key:value }, { key:value key:value } ] My object is array that doesn't have key. How could we parse this array? How should the…
Ahd Radwan
  • 1,090
  • 4
  • 14
  • 31
3
votes
2 answers

How to handle unexpected data types with Mantle

In my MTLModel subclass I have this: @property (assign, nonatomic) NSInteger catId; And of course this in the implementation: + (NSDictionary *)JSONKeyPathsByPropertyKey { return @{ @"catId" : @"cat_id" }; } But…
soleil
  • 12,133
  • 33
  • 112
  • 183
3
votes
0 answers

"dyld: Library not loaded" error with CocoaPods and watchOS 2

I'm getting the following error when trying to run Mantle via CocoaPods on watchOS 2: dyld: Library not loaded: @rpath/Mantle.framework/Mantle Referenced from: [...] Reason: image not found Mantle is working just fine in my main app - only the…
bmueller
  • 2,681
  • 1
  • 27
  • 45
3
votes
1 answer

ios Mantle - Overriding default initWithDictionary properly

I am facing the following problem.. I have a class Menu.h and Item.h. Menu is like a menu of a restaurant and has multiple categories (like appetizers, salads, etc) and each menu has multiple items associated. So Menu.h has an NSArray property…
Arpit Goel
  • 163
  • 1
  • 16
3
votes
2 answers

How to use Github Mantle's MTLValueTransformer with Swift?

Preface: I'm mostly an obj-c && swift n00b. I'm somewhat familiar with iOS and Cocoa frameworks through using RubyMotion for the past year. So if there's something wicked stupid or obvious I'm missing that would be why... I'm having trouble using…
tehprofessor
  • 2,957
  • 1
  • 21
  • 22