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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:33:36+00:00 2026-05-17T02:33:36+00:00

I currently have two UITextFields inside two corresponding UITableViewCells. This is how it looks:

  • 0

I currently have two UITextFields inside two corresponding UITableViewCells.

This is how it looks:

- (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];
}

// Configure the cell.

//adding all the UITextField's to the UITableViewCell is a pain in the ass. Pretty sure this is correct though.

if ([indexPath section] == 0) {
    tUser = [[UITextField alloc] initWithFrame:CGRectMake(110, 10, 185, 30)];
    tUser.adjustsFontSizeToFitWidth = YES;
    tUser.textColor = [UIColor blackColor];

    tPass = [[UITextField alloc] initWithFrame:CGRectMake(110, 10, 185, 30)];
    tPass.adjustsFontSizeToFitWidth = YES;
    tPass.textColor = [UIColor blackColor];

    if ([indexPath section] == 0) {
        if ([indexPath row] == 0) {
            tUser.placeholder = @"@JohnAppleseed";
            tUser.keyboardType = UIKeyboardTypeEmailAddress;
            tUser.returnKeyType = UIReturnKeyNext;
        }
        if ([indexPath row] == 1) {
            tPass.placeholder = @"Required";
            tPass.keyboardType = UIKeyboardTypeDefault;
            tPass.returnKeyType = UIReturnKeyDone;
            tPass.secureTextEntry = YES;
        }
    }

    tUser.backgroundColor = [UIColor whiteColor];
    tUser.autocorrectionType = UITextAutocorrectionTypeNo;
    tUser.autocapitalizationType = UITextAutocapitalizationTypeNone;
    tUser.textAlignment = UITextAlignmentLeft;

    tPass.backgroundColor = [UIColor whiteColor];
    tPass.autocorrectionType = UITextAutocorrectionTypeNo;
    tPass.autocapitalizationType = UITextAutocapitalizationTypeNone;
    tPass.textAlignment = UITextAlignmentLeft;

    tUser.clearButtonMode = UITextFieldViewModeNever;
    tPass.clearButtonMode = UITextFieldViewModeNever;

    [tUser setEnabled:YES];
    [tPass setEnabled:YES];

    //[tUser release];
    //[tPass release];
}
if ([indexPath section] == 0) { // Email & Password Section
    if ([indexPath row] == 0) { // Email
        cell.textLabel.text = @"Username";
        [cell addSubview:tUser];
        [tUser setText:[[NSUserDefaults standardUserDefaults] objectForKey:@"twitter_name_preference"]];
    }
    else {
        cell.textLabel.text = @"Password";
        [cell addSubview:tPass];
        [tPass setText:[[NSUserDefaults standardUserDefaults] objectForKey:@"twitter_pass_preference"]];
    }
}
return cell; }

As you can see, these work and when I load the UITableView the UITextFields load into the correct UITableViewCells. However, as you can see I pull two NSUserDefault objects, both placed into the corresponding UITextFields.

However, I then have another action attached to a save button which is displayed in the Navigation Bar.

-(void)save_clicked: (id) sender {

if ([tPass text] == nil) {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" 
                                                    message:@"There was no password entered, please enter the correct password and try again." 
                                                   delegate:self 
                                          cancelButtonTitle:@"Okay" 
                                          otherButtonTitles:nil];
    [alert show];
    [alert release];
}

else {
    NSLog(@"we can do something here soon...");

    //NSString *tUserString = [[NSString alloc] initWithFormat:@"Hello: %@", tUser.text];

    NSLog(@"We saved their username: %@", [tUser text]);
    NSLog(@"We saved their password: %@", [tPass text]);

    // here we will start saving the username and password, then obtaining the authentication shit.



}
}

However, when I call these NSLogs, tUser returns (null) but tPass returns the entered text. I am sure it is just a simple syntax error or something of the sort, as everything (from my point of view) looks like it should work. Albeit, it doesn’t.

Can someone aid me in figuring out what is wrong with the tUser UITextField and as to why it keeps returning (null)?

All help is appreciated!

  • 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-17T02:33:37+00:00Added an answer on May 17, 2026 at 2:33 am

    You’re adding new tUser and tPass text fields every time your cells get displayed. You should keep your cell creation code (adding of text fields) inside the if (cell == nil) block and configure those text fields outside of that block. That way, you won’t add new text fields every time tableView:cellForRowAtIndexPath: is called.

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

Sidebar

Related Questions

I currently have two anchor tags sending url queries to put votes inside a
I currently have two tables that look something like this: Table 1 Id |
I currently have this code that works. I have two questions. How do I
I currently have two arrays that look like this: Swatches: Array ( [0] =>
This is a fairly basic question, I currently have two tables and in the
I currently have two different models: User and Project . The User model has
I currently have two SQL commands. One retrieves a list of unique IDs from
I currently have two Backbone models: user and project. I would like to have
I currently have two apps: app1/ app2/ templates/ app1.html app2.html In app1.html, I'm including
I currently have two panels within another large panel. The left panel is for

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.