MantleArrayExtension 2.0.2

MantleArrayExtension 2.0.2

LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Jun 2018

Maintained by soranoba.

  • By
  • soranoba


Build Status Carthage compatible Version License Platform

MantleArrayExtension support mutual conversion between Model object and character-delimited String with Mantle.


Mantle only support Json and Dictionary.

This library is an extension that convert between array and model with Mantle.

  • Support these
    • Split a string with the specified character and convert it to model
    • Convert between array and model
    • Customizable transformer

What is Mantle ?

Model framework for Cocoa and Cocoa Touch


MantleArrayExtension is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'MantleArrayExtension'

How to use functions of MantleArrayExtension

Conversion between Model and String (or Array)

// String to Model
id<MAESerializing> model = [MAEArrayAdapter modelOfClass:model.class
                                              fromString:@"2017-01-29, 'Alice Brown', 1, 2, 3"

// Model to String
NSString* string = [MAEArrayAdapter stringFromModel:model

Model definition

Model MUST inherit MTLModel and conforms MAEArraySerializing.

#pragma mark - MAEArraySerializing

+ (NSArray* _Nonnull)formatByPropertyKey
    return @[ @"date", MAESingleQuoted(@"name"), MAEVariadic(@"scores") ];

+ (unichar)separator
    return ',';

+ (BOOL)ignoreEdgeBlank
    return YES;

Kind of format

  • @"propetyName"
    • Double quoted-string, single quoted-string or enumerate-string
  • MAEQuoted(@"propertyName")
    • Double quoted-string
  • MAESingleQuoted(@"propertyName")
    • Single quoted-string
  • MAEOptional(@"propertyName")
    • Optional
  • MAEVariadic(@"propertyName")
    • Group from this position as one array.
  • MAERaw(@"rawString"), MAERawEither(@[@"value1", @"value2"])
    • The string expect one of specified strings
  • MAERawEither(@[@"value1", @"value2"]).withProperty(@"propertyName")
    • MAERaw or MAERawEither associate with property.


You can use serializer for MAEArraySerializing object.

  • MAEArrayAdapter # stringTransformerWithArrayModelClass:
  • MAEArrayAdapter # variadicTransformerWithArrayModelClass:

For MAEArraySerializing property, it is used by default, so you do not need to specify it.

Other information

Please refer to documentation, unit tests and Mantle.


Pull request is welcome =D


MIT License