1

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: (works great)

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

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

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

What gives me the 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)
Segev
  • 19,035
  • 12
  • 80
  • 152
  • 2
    Do you have a really, really good reason to support iOS 4? Maintaining compatibility for an existing app I can understand, but _adding it in now_? – jrturton Jan 01 '13 at 15:17

2 Answers2

1

The Requirements section of the AFNetworking page states:

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

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.

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.

David Alber
  • 17,624
  • 6
  • 65
  • 71
  • Don't know how I missed that. That definitely made some progress. I've posted a followup question here: http://stackoverflow.com/questions/14118166/the-jkdictionary-class-is-private-to-jsonkit-and-should-not-be-used-in-this-fash. – Segev Jan 02 '13 at 07:11
0

Your best bet is to use a third party library for JSON processing on iOS 4 and earlier. I would recommend JSONKit. https://github.com/johnezang/JSONKit

rooftop
  • 3,031
  • 1
  • 22
  • 33