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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:03:16+00:00 2026-05-27T05:03:16+00:00

I’m not sure if I am approaching this the correct way so I need

  • 0

I’m not sure if I am approaching this the correct way so I need some help. I have a table with 5 rows for data to be entered. After the user enters all the data there is a button on the navigation bar that will add the data to the arrays. I want to set up another view controller that displays all of the data that has been entered by the user. I hope this makes sense. Here’s what I have so far.

- (void)viewDidLoad
{
[super viewDidLoad];

[self initWithStyle: UITableViewStyleGrouped];
self.navigationController.navigationBarHidden=NO;
//self.navigationItem.hidesBackButton = YES;

// Uncomment the following line to preserve selection between presentations.
 //self.clearsSelectionOnViewWillAppear = NO;

// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
 self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle: @"Done" style:UIBarButtonItemStylePlain target: self action: @selector(add)] autorelease];

course = [[NSMutableArray alloc] init];
date = [[NSMutableArray alloc] init];
scores = [[NSMutableArray alloc] init];
rating = [[NSMutableArray alloc] init];
slope = [[NSMutableArray alloc] init];


}

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

- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}


#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{

// Return the number of sections.
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return 5;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    cell.accessoryType = UITableViewCellAccessoryNone;

    if ([indexPath section] == 0) {

        if ([indexPath row] == 0) {
            UITextField *playerTextField = [[UITextField alloc] initWithFrame:CGRectMake(110, 10, 185, 30)];
            playerTextField.adjustsFontSizeToFitWidth = YES;
            playerTextField.textColor = [UIColor blackColor];
            playerTextField.placeholder = @"Required";
            playerTextField.keyboardType = UIKeyboardTypeDefault;
            playerTextField.returnKeyType = UIReturnKeyNext;
            playerTextField.text = [course objectAtIndex:indexPath.row];
            playerTextField.backgroundColor = [UIColor whiteColor];
            playerTextField.textAlignment = UITextAlignmentRight;
            [playerTextField setEnabled: YES];
            [cell addSubview:playerTextField];
            [playerTextField release];
        }
        else if([indexPath row] == 1){
            UITextField *playerTextField = [[UITextField alloc] initWithFrame:CGRectMake(110, 10, 185, 30)];
            playerTextField.adjustsFontSizeToFitWidth = YES;
            playerTextField.textColor = [UIColor blackColor];
            playerTextField.placeholder = @"Required";
            playerTextField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
            playerTextField.returnKeyType = UIReturnKeyDone;
            playerTextField.text = [date objectAtIndex:indexPath.row];
            playerTextField.backgroundColor = [UIColor whiteColor];
            playerTextField.textAlignment = UITextAlignmentRight;
            [playerTextField setEnabled: YES];
            [cell addSubview:playerTextField];
            [playerTextField release];
        }   
        else if([indexPath row] == 2){
            UITextField *playerTextField = [[UITextField alloc] initWithFrame:CGRectMake(110, 10, 185, 30)];
            playerTextField.adjustsFontSizeToFitWidth = YES;
            playerTextField.textColor = [UIColor blackColor];
            playerTextField.placeholder = @"Required";
            playerTextField.keyboardType = UIKeyboardTypeNumberPad;
            playerTextField.returnKeyType = UIReturnKeyDone;
            playerTextField.text = [scores objectAtIndex:indexPath.row];
            playerTextField.backgroundColor = [UIColor whiteColor];
            playerTextField.textAlignment = UITextAlignmentRight;
            [playerTextField setEnabled: YES];
            [cell addSubview:playerTextField];
            [playerTextField release];
        }  
        else if([indexPath row] == 3){
            UITextField *playerTextField = [[UITextField alloc] initWithFrame:CGRectMake(110, 10, 185, 30)];
            playerTextField.adjustsFontSizeToFitWidth = YES;
            playerTextField.textColor = [UIColor blackColor];
            playerTextField.placeholder = @"Required";
            playerTextField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
            playerTextField.returnKeyType = UIReturnKeyDone;
             playerTextField.text = [rating objectAtIndex:indexPath.row];
            playerTextField.backgroundColor = [UIColor whiteColor];
            playerTextField.textAlignment = UITextAlignmentRight;
            [playerTextField setEnabled: YES];
            [cell addSubview:playerTextField];
            [playerTextField release];
        }  
        else if([indexPath row] == 4){
            UITextField *playerTextField = [[UITextField alloc] initWithFrame:CGRectMake(110, 10, 185, 30)];
            playerTextField.adjustsFontSizeToFitWidth = YES;
            playerTextField.textColor = [UIColor blackColor];
            playerTextField.placeholder = @"Required";
            playerTextField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
            playerTextField.returnKeyType = UIReturnKeyDone;
            playerTextField.text = [slope objectAtIndex:indexPath.row];
            playerTextField.backgroundColor = [UIColor whiteColor];
            playerTextField.textAlignment = UITextAlignmentRight;
            [playerTextField setEnabled: YES];
            [cell addSubview:playerTextField];
            [playerTextField release];
        }  

    }
}
if ([indexPath section] == 0) { 
    if ([indexPath row] == 0) { 
        cell.textLabel.text = @"Course";
    }
    else if([indexPath row] == 1){
        cell.textLabel.text = @"Date";
    }
    else if([indexPath row] == 2){
        cell.textLabel.text = @"Score";
    }
    else if([indexPath row] == 3){
        cell.textLabel.text = @"Rating";
    }
    else if([indexPath row] == 4){
        cell.textLabel.text = @"Slope";
    }
}

return cell;    
}

- (BOOL)textFieldShouldEndEditing:(UITextField *)textField {
[course replaceObjectAtIndex:textField.tag withObject:textField.text];
[date replaceObjectAtIndex:textField.tag withObject:textField.text];
[scores replaceObjectAtIndex:textField.tag withObject:textField.text];
[rating replaceObjectAtIndex:textField.tag withObject:textField.text];
[slope replaceObjectAtIndex:textField.tag withObject:textField.text];
return YES;
}
  • 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-27T05:03:17+00:00Added an answer on May 27, 2026 at 5:03 am

    Wouldn’t it just be easier to put 5 text fields in a view? I don’t understand why you put them in a table view… If you want them to be scrollable, you can always just wrap your entire view in a scrollview, but I wouldn’t do this with a table. As far as I know, it’s generally bad to use a table view for input. It’s more like a way to provide a user a display of some data, e.g. an array of objects. Also, usually, if you’re using an NSMutableArray as a data source, you would also want your table data source methods like tableView:numberOfRowsInSection: to return a value based on the size of the array, rather than a magic, hard coded number.

    I also see you’re doing a lot of work in the code. You can have Interface Builder do all this stuff for you: just make a new UIViewController subclass with a xib that goes by the same name, design it in Interface Builder, and write the logic in the .m file.

    For example, let’s say I have a subclass of UIViewController called MyViewController, which has a view with 1 button ‘next’ and 2 UITextFields, conveniently called dateTF and scoreTF. My .h file would look something like this:

    #import <UIKit/UIKit.h>
    
    @interface MyViewController : UIViewController {
        IBOutlet UITextField *dateTF;
        IBOutlet UITextField *scoreTF;
    }
    
    @property (nonatomic, retain) UITextField *dateTF;
    @property (nonatomic, retain) UITextField *scoreTF;
    
    - (IBAction)clickedNext:(id)sender;
    
    @end
    

    Here we have a placeholder for the action that will be called when the “next” button is pressed, and 2 outlets to the text fields to retrieve the data from them. I don’t need an IBOutlet to the button because I won’t edit it.

    The .m file could look like this:

    #import "MyViewController.h"
    
    @implementation MyViewController
    
    @synthesize dateTF
    @synthesize scoreTF;
    
    // called when the button is clicked
    - (IBAction)clickedNext:(id)sender{
        NSString * date = self.dateTF.text;
        NSString * score = self.scoreTF.text;
        // do something with this data, like put up a model and go to the next view
    }
    
    @end
    

    This assumes I have a xib file that contains my UI. In the xib you’ll also need to make a few connections (easily done with ctrl+click_and_drag from source to target, e.g. from button to File’s Owner): you’ll need to connect the 2 IBOutlets and the button to call the IBAction, and you should be good to go.

    Hope this helps!

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

Sidebar

Related Questions

I have some data like this: 1 2 3 4 5 9 2 6
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to

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.