Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8224719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:10:05+00:00 2026-06-07T15:10:05+00:00

I’m trying to build my NSDictionnary to send to a request using the AFNetworking

  • 0

I’m trying to build my NSDictionnary to send to a request using the AFNetworking framework, but it seems that I’m quite confused about how to do it properly.

Here’s what the server is expecting :

{
    "limit":10,
    "filters":
    [
        {"field":"owner","operator":"EQUAL","value":"ownerId","type":"integer"},
        {"field":"date","operator":"GE","value":"30 Jun 2010 00:00:00","type":"date"},
    ],
    "order":[{"field":"date","order":"ASC"}],
    "page":0
}

What I’m trying to do (I don’t really know if it’s the right way to do it tbh), is to build a NSDictionary like the following :

NSDictionary *parameters = [NSDictionary dictionaryWithObjectsAndKeys:
                                @"10", @"chunkSize", 
                                [NSDictionary dictionaryWithObjectsAndKeys:
                                    [NSDictionary dictionaryWithObjectsAndKeys:@"owner", @"field", @"EQUAL", @"operator", @"ownerId", @"value", @"integer", @"type", nil],
                                    [NSDictionary dictionaryWithObjectsAndKeys:@"date", @"field", @"GE", @"operator", @"30 Jun 2010 00:00:00", @"value", @"date", @"type", nil],
                                    nil], @"filters",
                                [NSDictionary dictionaryWithObjectsAndKeys:
                                    [NSDictionary dictionaryWithObjectsAndKeys:@"date", @"field", @"ASC", @"order", nil],
                                    nil], @"order",
                                @"0", @"page",
                                nil];

But I have the following error when the view is loading :

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: '+[NSDictionary dictionaryWithObjectsAndKeys:]: second object of each pair must be non-nil

I know I screw up building the parameters properly, but I can’t manage to do it after several tries. Could anyone help ? Moreover, I don’t really know the differences that I must implement here with the [] and the {}. I read that {} was for a dictionary and [] for an array, but I don’t really see how to translate it in my case.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T15:10:07+00:00Added an answer on June 7, 2026 at 3:10 pm

    Your mistake is that the value for the dictionary starting on line 3 needs to be wrapped in an array.

    At least until Objective-C array and hash literals go mainstream, my preferred method for creating complex dictionaries is to build them from an NSMutableDictionary. In your case:

    NSMutableDictionary *mutableParameters = [NSMutableDictionary dictionary];
    [mutableParameters setValue:@"10" forKey:@"limit"];
    // ...
    
    NSMutableArray *mutableFilters = [NSMutableArray array];
    NSMutableDictionary *mutableOwnerFilterDictionary = [NSMutableDictionary dictionary];
    [mutableOwnerFilterDictionary setValue:@"owner" forKey:@"field"];
    // ...
    [mutableFilters addObject:mutableOwnerFilterDictionary]; 
    
    [mutableParameters setValue:mutableFilters forKey:@"filters"];
    // ...
    

    Also, be sure you’re sending that over as JSON by setting AFJSONParameterEncoding to your AFHTTPClient.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.