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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:26:46+00:00 2026-05-26T00:26:46+00:00

Occasionally, especially if I have played with settings or the app has been force

  • 0

Occasionally, especially if I have played with settings or the app has been force quit all the formatting is messed up because these values come back null.

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

        static NSString *CellIdentifier = @"Cell";

        bool bold = [[NSUserDefaults standardUserDefaults] boolForKey:@"bold"];    
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
            cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
            cell.textLabel.numberOfLines = 0;
        }

        int fontSize = [[NSUserDefaults standardUserDefaults] integerForKey:@"fontSize"];
        NSString *fontFace = bold? @"Helvetica":[[NSUserDefaults standardUserDefaults] stringForKey:@"fontFace"];
        cell.textLabel.font = [UIFont fontWithName:fontFace size:(float)fontSize];

        NSString *cellText = romanized? @"Romanized":@"Text";

        cell.textLabel.text = [[self.myDataArray objectAtIndex:indexPath.row] objectForKey:cellText];

        return cell;
    }

Edit with code from InAppSettingsKit, in my rootview controller I do this:

    - (void)settingsViewControllerDidEnd:(IASKAppSettingsViewController*)sender {
        [[NSUserDefaults standardUserDefaults] synchronize];
        [self dismissModalViewControllerAnimated:YES];
        // your code here to reconfigure the app for changed settings
    }
  • 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-26T00:26:47+00:00Added an answer on May 26, 2026 at 12:26 am

    When you force quit the app, the user defaults are not saved.

    My suggestion would be to check for every key at launch, if it exists, do nothing, if it doesn’t, set a default value to it.

    EDIT: This is how I’d do it for many objects:

    NSArray *keys = [NSArray arrayWithObjects:@"Key 1", @"Key 2", @"Key 3", nil];
    NSArray *defaultValues = [NSArray arrayWithObjects:@"Default Value", [UIFont systemFontOfSize:12], [NSNumber numberWithInteger:5], nil];
    for(NSInteger i = 0; i < [keys count]; i++){
      id object = [[NSUserDefaults standardUserDefaults] objectForKey:[keys objectAtIndex:i];
      if(!object)[[NSUserDefaults standardUserDefaults] setObject:[defaultValues objectAtIndex:i] forKey:[keys objectAtIndex:i]];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

occasionally several empty div tags are created under the comments block. They all have
Occasionally working in Windows Vista the O.S. will desaturate the screen, rendering all colors
We have an AIR application running on an Apple iPad, that occasionally experiences sudden
Occasionally I'll have some WPF C# code that I'd like to write in a
Occasionally while working with a Rails app, running the bundle install command freezes while
I've been using jQuery .find() to do xml traversal, and I'm finding that occasionally
Occasionally, I have had to build a SQL string in VBA and execute it
Occasionally I have a need to retry an operation several times before giving up.
I have a program that occasionally needs to scan some directories recursively (an improvement
I have an app that is using devise for authentication. Rails 3 on ruby

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.