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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:03:34+00:00 2026-05-27T21:03:34+00:00

I am developing a cocoa application. I created a user default object with this

  • 0

I am developing a cocoa application. I created a user default object with this code:

NSUserDefaults *standard_user_defaults = [NSUserDefaults standardUserDefaults];

if (standard_user_defaults) {
    [standard_user_defaults setObject:myString forKey:key];
    [standard_user_defaults synchronize];
}

And then, I am getting the value with this code:

NSUserDefaults *standard_user_defaults = [NSUserDefaults standardUserDefaults];
NSString *val = nil;

if (standard_user_defaults) 
    val = [standard_user_defaults objectForKey:key];

The problem is that if I run this application in my computer is working fine, and I can get the user default value, but if another person runs the application is getting an empty value. Any ideas?

  • 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-27T21:03:34+00:00Added an answer on May 27, 2026 at 9:03 pm

    I assume by “another person” you mean another user on your computer. The reason they cannot read what you’ve written to your user defaults is because NSUserDefaults is meant for user-specific values. To save something that your application will be able to access from both your user account and others’, you need to place it in a file stored somewhere in a shared location on the system. One way to do this would be something like this:

    NSString *basePath = [NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSLocalDomainMask, YES) objectAtIndex:0];
    NSString *filePath = [basePath stringByAppendingPathComponent:@"someFileName"];
    
    // write:
    NSDictionary *dataToSave = [NSDictionary dictionaryWithObjectsAndKeys:theValue, @"someKey", nil];
    if(filePath && [dataToSave writeToFile:filePath atomically:YES])
    {
        // success!
    }
    
    // read:
    NSDictionary *dataToLoad = [NSDictionary dictionaryWithContentsOfFile:filePath];
    if(dataToLoad)
    {
        // success!
        NSString *theValue = [dataToLoad objectForKey:@"someKey"];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a cocoa application for mac. I have created a preference window
I am developing an OS X/Cocoa application and I want behavior like this: There
I am developing a cocoa application that will be making heavy use of both
I am developing a Cocoa application which communicates constantly with a web service to
I'm developing a Cocoa/Obj-C application that involves a WebView (from the WebKit framework). I've
I'm developing an installation like cocoa application wich needs to take care of some
I'm trying to build my first cocoa application. done some iPhone developing before. I
I am developing an application in cocoa,which needs to check whether that app is
I'm a newbie Cocoa developer and I'm developing my first application. I want to
I'm fairly new to Cocoa and Objective-C. Currently I'm developing a fairly basic application

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.