2013-01-01 34 views
1

我正在將支持ios 5的項目轉換爲ios 4並遇到一些困難。 它使用類AFNetworking,我的問題是在下面一行:將NSJSONSerialization轉換爲ios 4

的iOS 5:(偉大工程)

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

因爲NSJSONSerialization中的iOS 4不支持我使用的是這樣的:

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) 
+2

您是否真的有很好的理由支持iOS 4?保持現有應用程序的兼容性我可以理解,但_現在_添加它? – jrturton

回答

1

Requirements section of the AFNetworking page狀態:

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

code for version 0.10.1掃視了一眼,我看到文件AFJSONUtilities.m,這似乎處理JSON解碼。這在最新版本的AFNetowrking中不存在,因爲它需要具有NSJSONSerialization的iOS 5或更高版本。

如果您尚未嘗試使用0.10.1版本,而不是修改當前版本以在iOS 4上運行,因爲在處理JSON問題後可能會遇到其他障礙。

+0

不知道我是如何錯過的。這無疑取得了一些進展。我在這裏發佈了後續問題:http://stackoverflow.com/questions/14118166/the-jkdictionary-class-is-private-to-jsonkit-and-should-not-be-used-in-this-fash 。 – Segev