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

The Archive Base Latest Questions

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

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject:@xxxxxxxx forKey:@name]; [defaults synchronize]; I need to know

  • 0
 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:@"xxxxxxxx" forKey:@"name"];

[defaults synchronize];

I need to know why do i have to use the last line of the above code [defaults synchronize] ? What is the purpose of using it? Is it a must ?

  • 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-31T02:56:34+00:00Added an answer on May 31, 2026 at 2:56 am

    The purpose of [default synchronize]; is to make the user defaults get written on disk immediately. You don’t need to call it explicitly, iOS already does it at appropriate moments. So you can remove that line. In fact, it’s a performance problem if you call synchronize every time you set a default.

    Prior to iOS 7, the user defaults were always synchronized when the application transitioned into background. As of iOS 7, that is no longer the case, so you might want to call synchronize in your app delegate’s applicationDidEnterBackground: or register to the UIApplicationDidEnterBackgroundNotification notification to do that.

    From the documentation for -[NSUserDefaults synchronize]:

    Because this method is automatically invoked at periodic intervals, use this method only if you cannot wait for the automatic synchronization (for example, if your application is about to exit) or if you want to update the user defaults to what is on disk even though you have not made any changes.

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

Sidebar

Related Questions

I have this piece of code NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; if (![defaults objectForKey:@firstRuns]){
I have this in my app delegate applicationDidFinishLaunching method: NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
i need to use the facebook api: in the appdelegate.m I have this code:
I need to save a NSMutableDictionary in NSUserDefaults. I have searched the web for
Hi I am trying to use NSUserDefaults to save some default values in database.
I have issues with NSUserDefaults and I don't quite understand what is going on.
I'm implementing saved data on my app by using NSUserDefaults, like this: [[NSUserDefaults standardUserDefaults]
I have the following IBAction set up: #define FAVORITES_KEY @GraphViewController.Favorites - (IBAction)addToFavorites:(id)sender { NSUserDefaults
I want to store a float value into NSUserDefaults . I also need to
I have an NSMutableArray saved with NSUserDefaults. This array is my favourite items that

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.