【问题标题】:iOS to android conversion for nsdictionary for http communication用于 http 通信的 nsdictionary 的 iOS 到 android 转换
【发布时间】:2013-08-17 20:32:51
【问题描述】:

我在 ios 应用程序中有以下代码,我正在将它们转换为 android。

NSDictionary *data1 = [[NSDictionary alloc] initWithObjectsAndKeys:[[UIDevice currentDevice] uniqueIdentifier],@"deviceUid",@"iPhone",@"deviceType",deviceToken,@"deviceToken", nil];

NSDictionary *data2 = [[NSDictionary alloc] initWithObjectsAndKeys:_emailTextField.text,@"email",_passwordTextField.text,@"password",device_data,@"deviceModel", nil];

现在这个data2被传递给https请求进行验证

parameters:data2

但是当我尝试将相同的代码转换为 android 时,我感到很困惑。 data2 将如何在 android 中存储 data1

服务器以 JSON 格式接收数据。

【问题讨论】:

    标签: android ios


    【解决方案1】:

    试试 HashMap

    Map  map =  new HashMap();
    map.put("key","Obj");
    map.put("secondkey","secondObj");
    map.put("thirdkey","thirdObj");
    

    检查此link 以了解 Map 到 JSON 的转换。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多