Skip to content

MessagePack implementation for Objective-C / msgpack.org[Objective-C]

License

Notifications You must be signed in to change notification settings

Blankdlh/MPMessagePack

 
 

Repository files navigation

MPMessagePack

Objective-C implementation for MessagePack.

MessagePack is an efficient binary serialization format. It lets you exchange data among multiple languages like JSON. But it's faster and smaller.

MPMessagePack uses gabriel/GRUnit for unit testing.

Install

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries in your projects.

Podfile

pod "MPMessagePack"

MPMessagePack

Writing

#import <MPMessagePack/MPMessagePack.h>

NSDictionary *dict =
  @{
    @"n": @(32134123),
    @"bool": @(YES),
    @"array": @[@(1.1f), @(2.1)],
    @"body": [NSData data],
  };

NSData *data = [dict mp_messagePack];

Or via MPMessagePackWriter.

NSError *error = nil;
NSData *data = [MPMessagePackWriter writeObject:dict error:&error];

If you need to use an ordered dictionary.

MPOrderedDictionary *dict = [[MPOrderedDictionary alloc] init];
[dict addEntriesFromDictionary:@{@"c": @(1), @"b": @(2), @"a": @(3)}];
[dict sortKeysUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
[dict mp_messagePack];

Reading

id obj = [MPMessagePackReader readData:data error:&error];

About

MessagePack implementation for Objective-C / msgpack.org[Objective-C]

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 71.1%
  • Objective-C 27.1%
  • Shell 1.2%
  • Ruby 0.6%