I use AFNetworking
to create request with NSDictionary *parameters
. One of my key value pairs are empty arrays:
NSMutableArray * array = [NSMutableArray new];
When I had created such example of parameters:
parameters = @{"ids": array, "name": "someName"};
Server received:
parameters = @{"name": "someName"};
Why the keys with empty arrays were removed?
After a long digging it turned out that the problem is with NSMutableArray
's method.
AFNetworking
uses at some moment NSMutableArray
's method addObjectsFromArray:
. It is not mentioned in Apple documentation, but this method adds nothing if array is empty.
When I replace my empty array with NSNull()
or array with one element NSNull()
the server do not receive it at all.
Anyone know how is it happening, or how to solve that problem?