将NSJSONSerialization转换为ios 4 [英] Converting NSJSONSerialization to ios 4

查看:71
本文介绍了将NSJSONSerialization转换为ios 4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将支持ios 5的项目转换为ios 4并遇到一些困难。
它使用类 AFNetworking ,我的问题在以下行:

I'm converting a project that supports ios 5 to ios 4 and having some difficulties. It uses the class AFNetworking and my problem is in the following line:

iOS 5 :(效果很好)

iOS 5: (works great)

self.responseJSON =[NSJSONSerialization JSONObjectWithData:self.responseData options:0 error:&error];

因为iOS不支持 NSJSONSerialization 4我正在使用它:

Because NSJSONSerialization isn't supported in iOS 4 I'm using this:

self.responseJSON = AFJSONDecode(self.responseData, &error);

什么给我错误:

Undefined symbols for architecture i386:
  "_AFJSONDecode", referenced from:
      -[AFJSONRequestOperation responseJSON] in AFJSONRequestOperation.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)


推荐答案

AFNetworking页面的要求部分状态:

The Requirements section of the AFNetworking page states:


为了与iOS 4.3兼容,请使用最新的0.10.x版本。

For compatibility with iOS 4.3, use the latest 0.10.x release.

浏览版本0.10的代码。 1 ,我看到文件 AFJSONUtili ties.m ,似乎可以处理JSON解码。这在AFNetowrking的最新版本中不存在,因为它需要具有NSJSONSerialization的iOS 5或更高版本。

Glancing at the code for version 0.10.1, I see the file AFJSONUtilities.m, which appears to handle JSON decoding. This is not present in the latest version of AFNetowrking since it requires iOS 5 or above, which has NSJSONSerialization.

您可能想要尝试版本0.10.1,如果您有还没有,而不是修改当前版本在iOS 4上工作,因为在处理JSON问题后你可能会遇到额外的障碍。

You might want to try version 0.10.1, if you have not already, rather than modifying the current version to work on iOS 4 because you may run into additional roadblocks after dealing with the JSON problem.

这篇关于将NSJSONSerialization转换为ios 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆