Latest 0.0.1b1
Homepage https://github.com/leverdeterre/SecureMappingKit
License MIT
Platforms ios 5.0, requires ARC
Frameworks CoreTelephony, UIKit
Authors

SecureMappingKit

Twitter
License MIT
Cocoapods
Travis

Securize your mapping between your JSON and your object.
What is security ? The library is in charge of the convertion of the JSON objects to your desired types.
If your are expected a NSDate and the JSON gives you a NSString, SecureMappingKit transforms it into the exepected class, using NSValueTransformer.

Actual tranformers :

  • [x] NSNumberTransformer,
  • [x] NSBooleanNumberTransformer, to be sure to have a NSNumber of a boolean
  • [x] NSStringTransformer,
  • [x] NSURLTransformer,
  • [x] NSArrayTransformer,
  • [x] NSDateTransformer,
  • [x] NSDecimalTransformer

+_+

  • [x] ThreadSafe,
  • [x] Memory usage, DateFormaters and ValueTransformers are allocated once and stored on the Thread dictionary.
  • [x] Secure mappings,
  • [x] lots of unit tests

Get SecureMappingKit (Soon)

If you use Cocoa Pods, you can get SecureMappingKit by adding to your podfile pod 'SecureMappingKit', '~>0.0.1b1'.

Using SecureMappingKit

On a NSDictionnary

- (id)objectForKey:(id)aKey expectedClass:(Class)expectedClass;
- (id)objectForKey:(id)aKey expectedClass:(Class)expectedClass withTransformerClass:(Class)transformerClass;
- (id)objectForKey:(id)aKey withTransformerBlock:(JMOTransformerBlock)transformerBlock;

- (NSNumber *)numberForKey:(id)aKey;
- (NSNumber *)boolNumberForKey:(id)aKey;
- (NSDecimalNumber *)decimalNumberForKey:(id)aKey;
- (NSString *)stringForKey:(id)aKey;
- (NSURL *)urlForKey:(id)aKey;
- (NSArray *)arrayForKey:(id)aKey;
- (NSDate *)dateForKey:(id)aKey usingDateFormat:(NSString *)dateFormat;

Configure optional values

[SecureMappingKit setDateFormatterForcedlocale:[NSLocale localeWithLocaleIdentifier:@"fr_FR"]];
[SecureMappingKit setDateFormatterForcedTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT"]];
[SecureMappingKit setLogEnable:YES];

On other classes ?

[NSNumber numberFromObject:obj];
[NSNumber boolNumberFromObject:@"true"];
[NSNumber boolNumberFromObject:@"1"];
[NSNumber boolNumberFromObject:@(1)];
[NSDecimalNumber decimalNumberFromObject:@"1,1"];
[NSString stringFromObject:@(1)];
[NSURL urlFromObject:@"https://developer.apple.com/design/"];
[NSDate dateFromObject:@"07/26/1982" usingDateFormat:@"MM/dd/yyyy"]

Using SecureMappingKit, implement SecureDecoding protocol

- (void)decodeObjectWithDictionary:(NSDictionary *)dict
{
    NSString *identifier = [dict objectForKey:@"id" expectedClass:NSString.class];

    //NSNumber has boolean
    NSNumber *isActive = [dict objectForKey:@"isActive" 
                              expectedClass:NSNumber.class 
                       withTransformerClass:NSBooleanNumberTransformer.class];

    //NSNumber
    NSNumber balance = [dict objectForKey:@"balance" expectedClass:NSNumber.class];

    //@{@"url":@"https://developer.apple.com/design/"}
    NSURL *url = [dict  objectForKey:@"url" expectedClass:NSURL.class];

    NSDate *date = [dict  dateObjectForKey:@"date" withDateFormat:@"MM/dd/yyyy"];
}

Latest podspec

{
    "name": "SecureMappingKit",
    "version": "0.0.1b1",
    "requires_arc": true,
    "authors": {
        "Morissard Ju00e9rome": "[email protected]"
    },
    "platforms": {
        "ios": "5.0"
    },
    "summary": "Securize the mapping between your JSON and your model.",
    "license": {
        "type": "MIT"
    },
    "homepage": "https://github.com/leverdeterre/SecureMappingKit",
    "source": {
        "git": "https://github.com/leverdeterre/SecureMappingKit.git",
        "tag": "0.0.1b1"
    },
    "source_files": "SecureMappingKit/SecureMappingKit/SecureMappingKit/*",
    "frameworks": [
        "CoreTelephony",
        "UIKit"
    ]
}

Pin It on Pinterest

Share This