zoukankan      html  css  js  c++  java
  • iOS MessagePack

    参考地址:http://msgpack.org
    Install
    pod "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];
    MPMessagePackReader *reader = [[MPMessagePackReader alloc] initWithData:data];
    id obj1 = [reader read:&error]; // Read an object
    id obj2 = [reader read:&error]; // Read another object
  • 相关阅读:
    hdoj_1016Prime Ring Problem
    毛玻璃
    HDOJ1175连连看
    const小结
    指向二维数组的指针
    关于对ACM OJ大数据递归栈溢出问题的解决方案
    Hessian的使用与介绍
    Tomcat调优
    ant使用
    ant使用
  • 原文地址:https://www.cnblogs.com/qingjoin/p/4191730.html
Copyright © 2011-2022 走看看