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

  • Home
  • SEARCH
  • 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 8637687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:32:18+00:00 2026-06-12T10:32:18+00:00

In class 1 i save a int converted to a string , in class

  • 0

In class 1 i save a int converted to a string, in class 2 I try to load this string for some reason it does not work, when I write the string which I get out of loadString to a text box in class 2 the text box stays empty.
When i do the same thing in class 1 the text box becomes “1”.

class 1.m

- (void)viewDidLoad
{
[super viewDidLoad];
countForString = 1;
saveString = [[NSString alloc]initWithFormat:@"%i", countForString];
[self SaveTextBox:saveString :@"Number"];
}

-(void)SaveTextBox:(NSString*)string :(NSString*)stringsave
{
NSString *savestring = string;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:savestring forKey:stringsave];
[defaults synchronize];
}

class 2.m

- (void)viewDidLoad
{
[super viewDidLoad];
[self loadString:@"Number":teamString];
tbTeamPlayer.text = teamString;
}

-(void)loadString:(NSString *)location:(NSString *)saveInString
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *loadstring = [defaults objectForKey:location];
saveInString = loadstring;
} 
  • 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-12T10:32:19+00:00Added an answer on June 12, 2026 at 10:32 am

    loadString:location: doesn’t change the value of saveInString, all it does is overwrite the local variable. You need to return the string and set that value, e.g.

    tbTeamPlayer.text = [self loadString:someLocation];
    

    and change loadString to do:

    - (NSString *)loadString:(NSString *)location
    {
        return [[NSUserDefaults standardUserDefaults] stringForKey:location];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written this utility class to save and retrieve HttpCookies. It seems not
I have various class which perform save and update operations of GUI elements, it
I have a class that I instantiate to save or load xml data. For
I have a actionSave class which extends AbstractAction.I use it for save button. somewhere
I've extended the Backbone Collection class to include a save method, which is essentially
I have the following class: class Item { public string[] field1; public int field2;
I'm using a singleton class to save all my settings info. It's first utilized
We save and read files by (de) serializing a class named DocumentClass. All was
I'm trying to save my Photo class that has a byte[] File field. When
I was trying to save one of the class object to a File using

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.