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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:42:57+00:00 2026-06-09T23:42:57+00:00

I am building my App conected to a Rest API and until now I

  • 0

I am building my App conected to a Rest API and until now I only made a GET request with the following code :

//Start login process
NSString *emailstring = email.text;
NSString *passstring = pass.text;

// Create the URL from a string.
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.myserver.com/Rest/API/users?format=json&email=%@&password=%@",emailstring,passstring]];
NSLog(@"%@",url);

// Create a request object using the URL.
NSURLRequest *request = [NSURLRequest requestWithURL:url];

// Prepare for the response back from the server    
NSHTTPURLResponse *response = nil;
NSError *error = nil;

// Send a synchronous request to the server (i.e. sit and wait for the response)
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSLog(@"Reponse from web:%@", response);

// Check if an error occurred    
if (error != nil) {
    NSLog(@"%@", [error localizedDescription]);
    // Do something to handle/advise user.

    UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Login error"
                                                      message:@""
                                                     delegate:nil
                                            cancelButtonTitle:@"OK"
                                            otherButtonTitles:nil];
    [message show];

}

else {

    // Convert the response data to a string.
    NSString *responseString = [[NSString alloc] initWithData:responseData  encoding:NSUTF8StringEncoding];

    // View the data returned - should be ready for parsing.
    NSLog(@"%@", responseString);

    // Add data to a Plist file for next time
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *path = [documentsDirectory stringByAppendingPathComponent:@"login.plist"];

    NSArray *values = [[NSArray alloc] initWithObjects:emailstring,passstring,@"IDtest",nil];
    [values writeToFile:path atomically:YES];
    [values release];


    [self dismissModalViewControllerAnimated:YES];
}

This code work fine just for a GET request. I saw it is there a lot of framework (e.g RestKit, ….). But I am getting a bit lost with other request ! So what is the best solution to make POST DELETE PUT request for an IOS App ?

  • 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-09T23:42:58+00:00Added an answer on June 9, 2026 at 11:42 pm

    It’s similar code, but using the class NSMutableRequest. You can set the httpbody and other parameters to communicate with the server.

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

    to post something, just put setHTTPMethod:@”POST”and assign the data to post using setHTTPBody:

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

Sidebar

Related Questions

Building an app using Phonegap and jquery on Android using this code to request
Below is partial code to an experimental http server app I'm building from scratch
Building an app using android.support.v4.app , targeting API level 8. Everything's working as planned
Building an app with the Facebook JavaScript API that will embedded into a page
I am building a Client server app in java ,here is my code Client
Im building an app which uses Sqlite DB. Users can enter their information into
Currently building an app that runs on mobile phones not related to the issue
I am building an app that performs a lot of client side data downloading
I am building an app that does a lot of math and calculations. I
I am building an app where I need to allow a user to add

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.