问题描述
我正在将支持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:
浏览,我看到文件,似乎可以处理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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!