AFNetworking/AFNetworking — Issue #200: Problems with JSON parsing: iOS 4.X + 5.0+
Author: kankurou
Created: 2012-02-04 07:11:18+00:00
State: open

I have JSONKit installed for iOS4.x compatibility. Here's what's happening:

AFNetworking + JSONKit + iOS 5.0+ = JSON parsing does not work (returns nil objects when trying to parse).
AFNetworking + iOS 5.0+ = JSON parsing works fine.
AFNetworking + JSONKit + iOS 4.X = JSON Parsing works
AFNetworking + iOS 4.X = JSON Parsing doesn't work (because obviously NSJSONSerializer is only available for iOS5.0+).

I temporarily fixed this in AFJSONUtilities.h by checking: if (_NSJSONSerializationClass && [_NSJSONSerializationClass respondsToSelector:_NSJSONSerializationSelector]) {
first then fall back to JSONKit for both encoding and decoding JSON. Removed the #ifdef _AFNETWORKING_PREFER_NSJSONSERIALIZATION_