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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:06:40+00:00 2026-06-14T14:06:40+00:00

Ok, since i’m new to obj-c and have a background in windows developing, i’m

  • 0

Ok, since i’m new to obj-c and have a background in windows developing, i’m searching for the counterpart of Regedit.

I’ve understand that i should use NSUserDefaults, right?

So, i have created two functions, one for setting and one for getting values. They look like this: (And yea… ignore my silly functions names) 🙂

//SET:
-(void)SetRegeditValue:(NSString*)Name:(NSString*)Value
{
    NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
    NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:Value,Name, nil];
    [ud registerDefaults:dict];
}
//GET:
-(NSString*)GetRegeditValue:(NSString *)Name
{
    NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
    NSString *get = [prefs stringForKey:Name];

    if(get)
        return get;
    else
        return @"Not found!";
}

And i use them like this:

//TO SET:
SetRegitValue:@"my_value":@"my_value_name";
//TO GET:
GetRegeditName:@"my_value_name";

I don’t know if this is the “right” way to do it, but it works.
The only thing is that when i kill the app, it does not remember these values and i get “Not found!”. Is there something i have to set so it REALLY saves these variables?

Oh, i’m building a cocoa application.

  • 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-14T14:06:41+00:00Added an answer on June 14, 2026 at 2:06 pm

    The registerDefaults: method is used to assign default values which get returned when you ask for an undefined key. To actually store a value, you need to use one of the set*:forKey: methods. Specifically, you should use setObject:forKey: since you are saving strings, which are objects.

    - (void)SetRegeditValue:(NSString *)name :(NSString *)value {
        [[NSUserDefaults standardUserDefaults] setObject:value forKey:name];
    }
    

    I used the same argument order that your code did, but note that it does not match the example you showed, which passed the value first.

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

Sidebar

Related Questions

Since now I have only used plugin for editing and the way I use
Since I'm new to coding and I'm trying to understand why here is a
Since black red tree is a binary search tree I have decided to use
since memcpy should be highly optimized nowadays, does it still make sense to optimize
Since I am developing an iOS >= 5.0 application, I am trying to change
Since REST is stateless, each request that comes in has no knowledge of the
Since input and raw_input() stop the program from running anymore, I want to use
Since I have no errors I don't know if this is the right place
Since the pages are stored in address_space within each inode, how does the background
since they have same rendering engine, this problem shows in both. it works great

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.