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

  • Home
  • SEARCH
  • 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 6190595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:37:01+00:00 2026-05-24T02:37:01+00:00

I am pretty new to iPhone/Objective-c programming. I’m struggling with an issue that doesn’t

  • 0

I am pretty new to iPhone/Objective-c programming. I’m struggling with an issue that doesn’t make sense to me. I am writing an app that, as part of the code, will consume restful services. The method I am writing to make Post calls, using the ASIHttpRequest library, looks like this:

- (NSString *) httpPostStringResponseUrl:(NSURL *)url:(NSDictionary *)args{
    ASIFormDataRequest  *request = [[[ASIFormDataRequest  alloc]  initWithURL:url] autorelease];

    NSArray *keys = [args allKeys];

    NSEnumerator *e = [args keyEnumerator];
    NSString* object;
    while (object = [e nextObject]) {
            NSLog(@"Adding to args key: %@", object);
        [request setPostValue:[keys valueForKey:object] forKey:object];
    }

    NSLog(@"Starting http POST request");
    [request startSynchronous];
    NSString *response = [request responseString];
    return response;
}

The idea is to pass in a dictionary of arguments and their values, and use them as the arguments to the POST request. However, when I run this code I get an NSUnknownKeyException.

This doesn’t make sense to me. The only access to the dictionary I am doing is using the keys provided by the iterator. So, how can they be part of the iterator and not be valid keys?

For completeness, here is the code where I call the above function:

NSMutableDictionary *params = [[[NSMutableDictionary alloc] init] autorelease];
NSURL *url = [[[NSURL alloc] initWithString:@"http://myURL"] autorelease];

[params setValue:@"user" forKey:@"Username"];
[params setValue:@"1234" forKey:@"Password"];

NSString *response = [web httpPostStringResponseUrl:url :params];

NSLog(@"Response is \"%@\"", response);
  • 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-05-24T02:37:02+00:00Added an answer on May 24, 2026 at 2:37 am

    The problem is that you’re trying to lookup the value for the key in the keys array, not in the args dictionary. Try something like this instead:

    for (NSString *key in args) {
            NSLog(@"Adding to args key: %@", key);
        [request setPostValue:[args objectForKey:key] forKey:key];
    }
    

    Note this also uses fast enumeration rather than explicit (slow) enumeration.

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

Sidebar

Related Questions

I'm new to iPhone and Objective C programming but I'm able to make my
I'm pretty new to iPhone development but I'm close to releasing my first app
I'm pretty new to iPhone development. I am building an app which has multiple
I'm pretty new to iPhone development and I'm still getting my head around Objective-C,
I'm working in the IPhone SDK, and am pretty new to objective-c. Right now
Im pretty new to objective-c programming and releasing of objects is my greatest headache.
I'm pretty new to iphone programming. I have come up with a problem when
I'm pretty new to Objective C and iPhone development and have hit a problem
I'm still pretty new to Objective -C and iPhone development and am trying to
I am pretty new to iphone programming therefore I apologize if my question could

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.