The best library for mapping master data

as a developer, I encounter data processing every day. The usual thing is that I need to process the raw data for an object (NSManagedObject). Therefore, I use AFNetworking to receive data from a remote server, and as a result of AFNetworking, I have data that NSDictionary can represent. Thus, the main thing that can take a lot of work is the conversion of this raw data into specific data models. Thus, there are many libraries on the Internet that can do this hard work for us:

MagicalRecord MagicalImport

Mantle

Easy mapping

So, as a new one in comparison, I want to know which library is better for my purposes. Perhaps you can also offer one more.

+6
source share
2 answers

Each of the libraries you mentioned has different goals:

MagicalRecord - simplifies general operations with master data (fetch, insert, delete, stack setup, etc.). It does not handle JSON mapping or any other format for Core Data models. Correction thanks to @casademora: MagicalRecord can handle imports using custom mappings using the steps described. However, MagicalRecord is a fairly large library, used only for this part of the functionality.

Mantle - significantly reduces the pattern for model objects in Objective-C (automatic implementations of NSCoding , NSCopying , -isEqual: / -hash , etc.). Includes adapters such as MTLJSONAdapter and MTLManagedObjectAdapter for converting between views of obejcts models. It sounds like itโ€™s best for what you are trying to achieve. If you implement the MTLJSONSerializing and MTLManagedObjectSerializing in your MTLModel subclass, you can turn NSDictionary responses from web APIs (supposedly JSON data) into Core Data model objects.

Easy mapping . I have not used this library myself, but it seems that it provides a small set of Mantle functions exclusively for converting between different representations of the model, except that it uses matching models ( EKObjectMapping ) instead of subclassing the base class of the model. The disadvantages of using this library are that it does not process any of the other Objective-C model object templates for you, as the Mantle does.

Of the 3 libraries mentioned, I think the Mantle will probably be the best fit for what you described. Another option is to use RestKit , which provides tighter REST API / Core Data integration than any of these libraries, but it is much more difficult to use debugging.

+5
source

If you need to close Core Data integration, you should look at RestKit ( http://restkit.org ). If you don't, I suggest EasyMapping. It is very easy and effective enough for almost all situations. Also, a subclass of classes from the framework class is not required (for example, MTLModel in the mantle)

+1
source

All Articles