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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:41:34+00:00 2026-05-26T18:41:34+00:00

How to store the values which are entered in different text fields to the

  • 0

How to store the values which are entered in different text fields to the Server in objective C, In my project i have created the a form where it consists of different text fields where the user has to enter the values to the text field, i have kept one SAVE button, where after entering the values to the text field the user has to click the Save button.

I have to save the values entered in the text fields to the server on the click of the SAVE Button.

So how to save the data or values to the server on the click of the SAVE button.

The Following is the code i have used to create the form,

In .h File :

#import <UIKit/UIKit.h>

#import "PickerViewController.h"

@interface PopAppViewController : UIViewController < NumberPickedDelegate>{

UIPopoverController *popOverController;
    UIPopoverController *popOverControllerWithPicker;
    PickerViewController *pickerViewController;
    IBOutlet UITextField *txtTest;
    IBOutlet UITextField *txtSun;
    IBOutlet UITextField *txtMon;
    IBOutlet UITextField *txtTue;
    IBOutlet UITextField *txtWed;
    IBOutlet UITextField *txtThurs;
    IBOutlet UITextField *txtFri;
    IBOutlet UITextField *txtSat;
    IBOutlet UITextField *txtTotal;
    IBOutlet UITextField *txtTask;
    IBOutlet UITextField *txtProject; 

}

@property (nonatomic, retain) UIPopoverController *popOverController;
@property (nonatomic, retain) UIPopoverController *popOverControllerWithPicker;
@property (nonatomic, retain) PickerViewController *pickerViewController;
@property (nonatomic, retain) UITextField *txtTest;
@property (nonatomic, retain) UITextField *txtSun;
@property (nonatomic, retain) UITextField *txtMon;
@property (nonatomic, retain) UITextField *txtTue;
@property (nonatomic, retain) UITextField *txtWed;
@property (nonatomic, retain) UITextField *txtThurs;
@property (nonatomic, retain) UITextField *txtFri;
@property (nonatomic, retain) UITextField *txtSat;
@property (nonatomic, retain) UITextField *txtTotal;
@property (nonatomic, retain) UITextField *txtTask;
@property (nonatomic, retain) UITextField *txtProject;


-(IBAction)displayPickerPopover;
-(IBAction)exit;
-(IBAction)reset;
-(IBAction)save;
-(IBAction)total;


@end

In .m file :

#import "PopAppViewController.h"
//#import "TimeSheetDatabase.h"

@implementation PopAppViewController

@synthesize popOverController,popOverControllerWithPicker,pickerViewController,txtTest,txtSun,txtMon,txtTue,txtWed,txtThurs,txtFri,txtSat,txtTotal,txtTask,txtProject;




//-(id)initWithtxtProject:(NSString *)txtProject txtTask:(NSString *)txtTask txtSun:(int)txtSun txtMon:(int)txtMon txtTue:(int)txtTue txtWed:(int)txtWed txtThurs:(int)txtThurs txtFri:(int)txtFri txtSat:(int)txtSat txtTotal:(int)txtTotal{
//    
//    self=[super init];
//    if(self){
//        self.txtProject = txtProject;
//        self.txtTask = txtTask;
//        self.txtSun = txtSun;
//        self.txtMon = txtMon;
//        self.txtTue = txtTue;
//        self.txtWed = txtWed;
//        self.txtThurs = txtThurs;
//        self.txtFri = txtFri;
//        self.txtSat = txtSat;
//        self.txtTotal = txtTotal;
//        
//    }
//}


-(IBAction)displayPickerPopover {
    [txtTest resignFirstResponder];
    CGSize sizeOfPopover = CGSizeMake(300, 422);
    CGPoint positionOfPopover = CGPointMake(32, 325);
    [popOverControllerWithPicker presentPopoverFromRect:CGRectMake(positionOfPopover.x, positionOfPopover.y, sizeOfPopover.width, sizeOfPopover.height)
                                                 inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}

-(IBAction)exit{

    exit(0);
}

-(IBAction)reset{

    txtSun.text = @"";
    txtMon.text = @"";
    txtTue.text = @"";
    txtWed.text = @"";
    txtThurs.text = @"";
    txtFri.text = @"";
    txtSat.text = @"";
    txtTotal.text = @"";
    txtTest.text = @"";
    txtTask.text = @"";
}

-(IBAction)save{



}


-(IBAction)total{

    int result = [txtSun.text intValue] + [txtMon.text intValue] + [txtTue.text intValue] + [txtWed.text intValue] + [txtThurs.text intValue] + [txtFri.text intValue] + [txtSat.text intValue];
    txtTotal.text = [NSString stringWithFormat:@"%d",result];

}




/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/

-(void)numberDidChangeTo:(NSString *)newNumber {
    txtTest.text = newNumber;
}

-(void)didChangeSelection:(NSString *)newValue {
    txtTest.text = newValue;
}

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {


    pickerViewController = [[PickerViewController alloc] init];
    pickerViewController.delegate = self;
    popOverControllerWithPicker = [[UIPopoverController alloc] initWithContentViewController:pickerViewController];
    popOverController.popoverContentSize = CGSizeMake(300, 216);

//    NSArray *timesheetinfo = [[TimeSheetDatabase database]getAllTimeSheet];
//    for(timesheetinfo *info in timesheetinfo){
//        
//        NSLog(@"%@ - %@ ",info.project,info.task);
//    }

    [super viewDidLoad];
}



// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {

    [popOverController release];
    [popOverControllerWithPicker release];
    [pickerViewController release];
    [txtTest release];
    [super dealloc];
}

@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-05-26T18:41:35+00:00Added an answer on May 26, 2026 at 6:41 pm

    You need to compile the data into a JSON string, and then send it to the server with an NSURLRequest

    -(IBAction)save
    {
      // build JSON string
      NSDictionary *postDictionary = [NSDictionary dictionaryWithObjectsAndKeys:self.txtTest.text, @"test",
                                                                                self.txtSun.text, @"sun",
                                                                                self.txtSun.text, @"mon",
                                                                                nil];
      NSData *postData = [NSJSONSerialization dataWithJSONObject:postDictionary options:NSJSONWritingPrettyPrinted error:NULL];
    
      // perform http request (on a background thread)
      dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
      dispatch_async(queue, ^{
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    
        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:@"http://example.com/save.php" cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60];
        [request setHTTPMethod:@"POST"];
        [request setHTTPBody:postData];
    
        NSHTTPURLResponse *urlResponse = nil;
        NSError *error = NULL;
        NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];
    
        // and now go back to the main thread
        dispatch_async(dispatch_get_main_queue(), ^{
          NSAutoreleasePool *mainQueuePool = [[NSAutoreleasePool alloc] init];
    
          // debug: print response
          NSLog(@"%@", [[NSString alloc] initWithData:responseData encoding:NSISOLatin1StringEncoding]);
    
          // check for http error (this includes php exceptions)
          if ([urlResponse statusCode] != 200) {
            NSLog(@"save failed with status code != 200");
            return;
          }
    
          [mainQueuePool release];
        });
    
        [pool release];
      });
    }
    

    And in your php:

    $rawData = file_get_contents("php://input");
    $postData = json_decode($rawData);
    
    print_r($postData);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the situation, I created 6 pages,each of which has some text fields.I stored
I have a form in which an address will be entered and I want
The Back Story I have some decimal values which I am displaying as strings
Is there a way to store values on client side permanently? I have a
i have made user-register.tpl.php file. And i have set many text field in that.
I have a textbox in asp page which is a concrete view. User enters
a software called livecycle has got forms with different fields in which data is
I am working on a project in CakePHP 1.3 which will store a collection
I need to store user entered changes to a particular table, but not show
I have a form in which I have an add button. When the 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.