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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:24:06+00:00 2026-05-24T14:24:06+00:00

I will be storing a few strings (maybe 10-20). I am not sure if

  • 0

I will be storing a few strings (maybe 10-20). I am not sure if I should use NSUserDefaults to save them, or write them out to a plist. What is considered best practice? NSUserDefaults seems like it is less lines of code, therefore quicker to implement.

I’d like to add that these string values will be added/removed by the user.

  • 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-24T14:24:07+00:00Added an answer on May 24, 2026 at 2:24 pm

    I am assuming an array, but it will work with dictionaries too.

    Userdefaults, Core Data and Plists can all be read/write but if you use a plist you need to pay attention in what dir you put it. See the plist part down below.

    Core Data I think it’s way too much overkill, it’s just strings.
    It’s supposed to be used when you want to persist more complex objects.

    NSUserDefaults:

    It’s pretty fast and easy to do, though it’s supposed to store only user settings.
    To write them to the userdefaults:

    NSArray *stringsArray = [[NSArray alloc] arrayWithObjects: string1, string2, string3, nil];
    [[NSUserDefaults standardUserDefaults] setObject:stringsArray forKey:@"MyStrings"];
    [[NSUserDefaults standardUserDefaults] synchronize];
    

    To read the from the userdefaults:

    NSArray *stringsArray = [[NSUserDefaults standardUserDefaults] objectForKey:@"MyStrings"];
    

    Plist:

    If your strings are going to be modified you will need to write and read a plist but you cant’t write into your app’s resources.

    1. To have a read/write plist first find the documents directory

      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
      NSString *stringsPlistPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Strings.plist"];
      
    2. Create the array (I am assuming the strings are string1, …)

      NSArray *stringsArray = [[NSArray alloc] arrayWithObjects: string1, string2, string3, nil];
      
    3. Write it to file

      [stringsArray writeToFile:stringsPlistPath atomically:YES];
      

    To read the plist:

    1. Find the documents directory

      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
      NSString *stringsPlistPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Strings.plist"];
      
    2. Read it in:

      NSArray *stringsArray = [NSArray arrayWithContentsOfFile:stringsPlistPath];
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I asked a few questions about SQLite here, and maybe its because I'm not
I'm building a social networking type site that will be storing large chunks of
I'm trying to write a class that will return a string of HTML with
My question is concerning an application that will use a host application where the
i am getting 'Index out of range exception unhandled' in my form1.i will be
In the class section of my code, if I write an error a few
I'm at a loss, a simple use of swing worker. I added a few
I've ran into an issue where code classes outside of my control use strings
When you do not explicitly set the width of a ListBox, it will automatically
imagine if you will the following string: A Great Movie (1999) DVDRip.avi I am

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.