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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:52:45+00:00 2026-06-13T08:52:45+00:00

Ok simple question but can’t find an answer. I’v got a button to save

  • 0

Ok simple question but can’t find an answer.

I’v got a button to save information in my app.
I have

  NSMutableArray *textFields = [[NSMutableArray alloc] initWithCapacity:5];
    UITextField *textField = nil;

This is the information i want to save, i’v got 5 textfields in textFields mutablearray.

[save addTarget:self action:@selector(saveInfo)
 forControlEvents:UIControlEventTouchUpInside];

and

-(void)saveInfo {
    [[[NSUserDefaults standardUserDefaults] setValue: ????? forKey:@"Phone"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

The question is how to access and get information from like textFields[1].text in my saveInfo void ?

Ok To get things a little bit clearer i’v added the whole class. its not very big, and maybe someone could see thats the problem with my implementation .

@implementation Settings

- (id)init: (TableViewController*) TableControll {
  NSMutableArray *textFields = [[NSMutableArray alloc] initWithCapacity:5];
    UITextField *textField = nil;

    for (int i = 0; i < 3; i++) {
        textField = [[UITextField alloc] initWithFrame:CGRectMake(0.0f, 0.0f+(i*35), 120.0f, 30.0f)];
        textField.backgroundColor = [UIColor whiteColor];
        [textField setBorderStyle:(UITextBorderStyleRoundedRect)];
        [TableControll.view addSubview:textField];

        [textFields addObject:textField];
        [textField release]; textField = nil;
    }
    UITextField *textName = textFields[0];
    textName.placeholder = @"Vardas";

    UITextField *textNo = textFields[1];
    textNo.placeholder = @"Telefonas";
    textNo.keyboardType = UIKeyboardTypeNumberPad;
    UITextField *textPin = textFields[2];
    textPin.keyboardType = UIKeyboardTypeNumberPad;
    textPin.placeholder = @"Pin";

    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button.frame = CGRectMake(150, 20, 160, 30);
    [button setTitle:@"Advanced settings" forState:UIControlStateNormal];
    [TableControll.view addSubview:button];
    UIButton *save = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    save.frame = CGRectMake(150, 60, 160, 30);
    [save setTitle:@"Save settings" forState:UIControlStateNormal];
    [TableControll.view addSubview:save];
    [button addTarget:self action:@selector(goAdvanced)
     forControlEvents:UIControlEventTouchUpInside];
    [save addTarget:self action:@selector(saveInfo)
     forControlEvents:UIControlEventTouchUpInside];

    return self;
}

-(void)goAdvanced {
    AppDelegate *newControll = (AppDelegate*)[UIApplication sharedApplication].delegate;
    [newControll ChangeController];
}

-(void)saveInfo {

    for(int i=0;i<5;i++) {
        UITextField *tempTxtField=[_textFields objectAtIndex:i];
        NSLog(@"do it %@",tempTxtField.text);
    }

}

@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-06-13T08:52:46+00:00Added an answer on June 13, 2026 at 8:52 am

    What you’d want to do if you are using interface builder is create a bunch of IBOutlet for your textfields instead of keeping them in an array. Check out this: tutorial

    Now it looks like you’re creating things by hand, so in this case, you probably just want to declare your array as @property so it can be accessed by your save method.

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

Sidebar

Related Questions

simple question maybe but can't find solution. I have button for refresh/update some contents
very simple question (but I can't find the answer on the Web...): I have
I have a simple question but I can't find an answer (please give me
I have this simple question actually but I can't find the correct answer. I
Perhaps a simple question but I can't find the answer. I have a web
This may be a simple question but I can;t find the answer anywhere. Here
Ok simple question but can't find an answer.. I need to pass my viewcontroller
A simple question but I can't find the answer in my book. I want
I would have a quite simple question, but can't find any suitable automated solution
This seems like a really simple question but I can't seem to find information

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.