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 8405753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:54:50+00:00 2026-06-09T22:54:50+00:00

I have a pretty basic internal iOS app that I want to send a

  • 0

I have a pretty basic internal iOS app that I want to send a POST to a web-server. You basically have a bunch of buttons, and depending on what button you press, it sends a pre-defined “message” to the web-server.

Once the buttons are pressed it takes them to another view and says Thanks for selecting the button that you pressed. I also want a pre-defined message to be sent to a web-server, formatted and then emailed to a static email address.

This is what I have so far.. I’m just trying to figure out the best way to send the POST. Is the way I have setup the best way to do it? Or is there smarter way to do this?

Sorry if it’s messy and un-organized.. I’m very new to iOS development.

@interface DrinkViewController () {
NSString *buttonlabel;
NSString *urlEncodeUsingEncoding;
}
@end

@implementation DrinkViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}

-(IBAction)selectButton:(id)sender{
    NSLog(@"Button Pressed:%d",((UIButton *)sender).tag);
    NSString *dvalue;
    switch (((UIButton *)sender).tag) {
        case 1:
            dvalue = @"Button 1";
            break;
        case 2:
            dvalue = @"Button 2";
            break;
        case 3:
            dvalue = @"Button 3";
            break;
        case 4:
            dvalue = @"Button 4";
            break;
        case 5:
            dvalue = @"Button 5";
            break;
        case 6:
            dvalue = @"Button 6";
            break;
        case 7:
            dvalue = @"Button 7";
            break;

    }
    buttonlabel = dvalue;

    [self performSegueWithIdentifier:@"selectionTransition" sender:sender];


    NSData *postData = [buttonlabel dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
    NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
    NSMutableURLRequest *request =  [NSMutableURLRequest alloc];
                                    [request setURL:[NSURL URLWithString:@"http://www.abc.com/form.php"]];
                                    [request setHTTPMethod:@"POST"];
                                    [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
                                    [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
                                    [request setHTTPBody:postData];
    NSLog(@"POST: %@ sent to %@", buttonlabel, request);
}


- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"selectionTransition"]) {

        NSLog(@"%@", buttonlabel);
        // Get destination view
        DetailViewController *vc = [segue destinationViewController];

        // Pass the information to your destination view
        [vc setLabelValue:buttonlabel];
    }
}

@end
  • 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-09T22:54:51+00:00Added an answer on June 9, 2026 at 10:54 pm

    Here’s what you need to use: NSURLRequest, NSURLConnection, NSURLResponse, NSURL. You might use another library, but i would recommend you to try to understand how these classes work (since you are new to this).

    https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURLRequest_Class/Reference/Reference.html

    https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/nsurlconnection_Class/Reference/Reference.html

    https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURLResponse_Class/Reference/Reference.html

    https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/Reference/Reference.html

    Here’s how it works: You use the server url, create a NSURLRequest, assign the proper HTTP method(POST, GET, etc) and other necessary request headers, then you would call on NSURLConnection to get the response and the server data.

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

Sidebar

Related Questions

I have a pretty basic app flow that is quite linear, so it fits
I have some pretty basic HTML/CSS that isn't working as I expect. Basically I
I have a pretty basic X11 app that I run on Linux that I'm
I have a pretty basic slideshow fading between images. On top of that slideshow
I am writing a pretty basic php app and have created a pretty big
This is a pretty basic question. Since browsers have a culture setting that the
I have a pretty basic question that confuses me for some strange reason. I
I have a pretty basic question that I imagine would require a join to
I have a pretty basic java applet that allows users to use a signature
I have a pretty basic 'User' model, control & views for a Rails app.

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.