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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:18:45+00:00 2026-06-03T04:18:45+00:00

I save value that user have been entered using NSUserDefaults. All works fine and

  • 0

I save value that user have been entered using NSUserDefaults. All works fine and data saves and retrieves. But how can I set a default value for that UITextField? When I use

- (void)viewDidLoad
{
    textField.text = @"12345";
}

or put Text in nib file doesn’t work, app start with empty field.

- (IBAction) saveBtnPresssed : (id) sender
{
    myString1 = [[NSString alloc] initWithFormat:textField.text];
    [textField setText:myString1];
    NSUserDefaults *stringDefault = [NSUserDefaults standardUserDefaults];
    [stringDefault setObject:myString1 forKey:@"stringKey"];
     NSLog(@"%@",myString1);
}
  • 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-03T04:18:47+00:00Added an answer on June 3, 2026 at 4:18 am

    I wouldn’t set the values yourself, XCode provides a far easier way of doing this using bindings.

    The way in which this works, would be you’d set your textfield a binding, and give it a name so that it can be identified, such as ‘intialTextField’. The value is then automatically stored in NSUserDefaults, and updated on application close.

    In XCode, click on the textField you want to bind, then open the Inspector. Then click the Tab second from the right. This is the ‘bindings’ tab.

    Click the drop-down arrow on the ‘Value’ field and check the ‘Bind to User Defaults…’

    In the ‘Model key path’, set the name you want to identify your textfield with, this can be anything you want.

    Then, whenever you enter something in your TextField, it will be saved on application exit. If you need this value to be saved straight away (only in rare cases is this necessary), you can enter the following code in your application:

    [yourTextField synchronize];
    

    On application startup you can then use NSUserDefaults to re-set the value of the textfield with the identifier you set earlier.

    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 been trying to use/save the boolean value of a checkbox in other
I am using the following code to save values from a settings view that
Possible Duplicate: How to save in the dropdown the value choosed? I have a
I am using ruby key & value fields to save a jquery function to
I have a MySQL database where I am storing information that is entered from
I have a small front end to a webshop. All customers that go through
I have a page which displays a form that a logged-in user can use
Environment: I have that User entity : @Entity public class User implements Serializable {
I have been building a core data application to administrate some data and I've
I have been stuck with this issue now all morning. I actually saw this

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.