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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:24:18+00:00 2026-06-14T17:24:18+00:00

Newbie obj-c question. I have a custom tableview with four custom cells. In every

  • 0

Newbie obj-c question.

I have a custom tableview with four custom cells. In every cell is a editable textfield for customer info. I need to improve switching between textfields by Input Accessory View.
http://uaimage.com/image/62f08045

I created an NSMutableArray with capacity 4. I tagged textfields and added them in this array in text field delegate method:

- (BOOL) textFieldShouldReturn:(UITextField *)textField {
    FDTextFieldCell *cell = (FDTextFieldCell *)[textField superview];
    NSIndexPath *indexPath = [[self tableView] indexPathForCell:cell];

    if ([indexPath section] == 0) {
        if ([indexPath row] == 0) {
            [[FDProfile sharedProfile] setName:[textField text]];
            [textField setTag:1];
            [textFieldsArray insertObject:textField atIndex:0];
        } else if ([indexPath row] == 1) {
            [[FDProfile sharedProfile] setSurname:[textField text]];
            [textField setTag:2];
            [textFieldsArray insertObject:textField atIndex:1];
        } else if ([indexPath row] == 2) {
            [[FDProfile sharedProfile] setNickname:[textField text]];
            [textField setTag:3];
            [textFieldsArray insertObject:textField atIndex:2];
        } else if ([indexPath row] == 3) {
            [[FDProfile sharedProfile] setEmail:[textField text]];
            [textField setTag:4];
            [textFieldsArray insertObject:textField atIndex:3];
            [textField resignFirstResponder];
        }
    }

    [[self tableView] reloadData];
    return YES;
}

Now i try to improve functionality of button “Next”:

- (void) inputAccessoryViewDidSelectNext:(FDInputAccessoryView *)view {
    for (UITextField *textField in [self textFieldsArray]) {
        if ([textField isFirstResponder]) {
     textField = [[self textFieldsArray] objectAtIndex:textField.tag + 1];
            [textField becomeFirstResponder];
        }

    }
}

But this code doesn’t works. I think there is an issue with using fast enumeration?

Can somebody help with this?
Thanks, Alex.


Some ideas to solving from c-had:

  1. Why are you setting up your textFieldsArray in textFieldShouldReturn:? Shouldn’t this be done somewhere where initialization is done (e.g. viewDidLoad of the view controller)? The problem might be that your array is never actually set up, or is only partly set up. Also, putting the setup here means it will be called over and over, mutating your array each time and screwing things up.
  2. Your tags are off by one. You should be assigning them starting at 0, not 1 (or accounting for the difference in inputAccessoryViewDidSelectNext:). If your code was working, it would skip 2 text fields, as the first field would return tag 1, and you’d skip to objectAtIndex:2, which is the 3rd field.
  3. You don’t account for going off the end. If you’re at the last field, incrementing will not go back to the beginning.

I’d actually recommend not using tags at all. Instead, at setup time, just loop through the fields adding them in order to your array. Then, in inputAccessoryViewDidSelectNext:, use a counter instead of fast enumeration to figure out where you are.

  • 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-14T17:24:19+00:00Added an answer on June 14, 2026 at 5:24 pm
    1. Why are you setting up your textFieldsArray in textFieldShouldReturn:? Shouldn’t this be done somewhere where initialization is done (e.g. viewDidLoad of the view controller)? The problem might be that your array is never actually set up, or is only partly set up. Also, putting the setup here means it will be called over and over, mutating your array each time and screwing things up.
    2. Your tags are off by one. You should be assigning them starting at 0, not 1 (or accounting for the difference in inputAccessoryViewDidSelectNext:). If your code was working, it would skip 2 text fields, as the first field would return tag 1, and you’d skip to objectAtIndex:2, which is the 3rd field.
    3. You don’t account for going off the end. If you’re at the last field, incrementing will not go back to the beginning.

    I’d actually recommend not using tags at all. Instead, at setup time, just loop through the fields adding them in order to your array. Then, in inputAccessoryViewDidSelectNext:, use a counter instead of fast enumeration to figure out where you are.

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

Sidebar

Related Questions

I have a newbie question about the following: - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
Total newbie Iphone/ Obj. C question: I have a class called Location, in the
I am a newbie in Obj-C. I need to learn this better so please
Newbie question... The objective: I intend to have an HTML text input field as
I have a PyMongo newbie question: If collection is a PyMongo Collection and I
I have very newbie question. How can i check that object of model is
Newbie question here but for some reason I cant figure this out. I have
I have a question. I am a newbie with Run Time Type Information from
Good day, friends. Once again stupid question about Obj-C from newbie :) I'm trying
Newbie obj-c question. My task is to make visually represented test for iPad. In

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.