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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:20:09+00:00 2026-06-02T07:20:09+00:00

Hello i have two Custom UITableViewCell nib, and i give the option to the

  • 0

Hello i have two Custom UITableViewCell nib, and i give the option to the users to choose what type of nib choose in the setting, i initialize the custom view cell in this way:

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

static NSString *CellIdentifier = @"MasterViewCell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];


if (cell == nil) {
    [[NSBundle mainBundle] loadNibNamed:[[NSUserDefaults standardUserDefaults] valueForKey:@"CustomCellViewKey"] owner:self options:nil];

    cell = customCell;
    self.customCell = nil;

}

 return cell;
}

as you can see i save the choose of the users in a NSUserDefaults that is the name of the xib, but when i return on my view, the cell view is not changed, and i have to exit from the application, close the app from the background, and reopen it, and the new view it’s loaded, so there is a method to reload my view without exit from the 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-02T07:20:11+00:00Added an answer on June 2, 2026 at 7:20 am

    So, the way NSUserDefaults works is that even if you use setValue:forKey: (or one of the other setter convenience methods), it doesn’t actually get written out immediately. The OS tries to optimize the saving of that plist by only doing so after a period of time, when the app quits, etc. Prior to that time, the value you set is simply cached to keep the OS from having to open and close the database numerous times. So when you try and get the value out for the cell, it’s going to the database and retrieving what may be an old value. When you quit the app, NSUserDefaults writes out the new value you set, and when you come back, you’re getting that correct value.

    To “force” NSUserDefaults to write to the database immediately, try calling synchronize immediately after you set the value based on the user’s input. This will write out to the database, so when you call your valueForKey: method, you should get the correct thing back.

    UPDATE: I would also restructure this method’s logical flow. First of all, if you are unloading two cells from two different nibs, they need two different reuse identifiers. Otherwise your tableview is out hunting for cell1’s to reuse when it really needs cell2’s. Try something like this:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        NSString *nibName = [[NSUserDefaults standardUserDefaults] valueForKey:@"CustomCellViewKey"];
    
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:nibName];
    
        if (!cell) {
            NSArray *nibArray = [[NSBundle mainBundle] loadNibNamed:nibName owner:self options:nil];
            for (id obj in nibArray) {
                if ([obj isKindOfClass:[UITableViewCell class]]) {
                    cell = obj;
                    break;
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

1) I have created a custom object Hello . Added two lookup fields to
I have two android applications. The apks are Hello.apk and Fonts.apk I would like
I have two arrays: $array1 = array(1=>1,10=>1,12=>0,13=>13); $array2 = array(1=>Hello,10=>Test,12=>check,13=>error); Here $array1 has keys
Hello I have problem to put together animations of two separate objects to second
Let's say I have these two arrays: string[] arr1 = new string[2]{Hello, Stack} string[]
Hello I have two dependants select box, the second one is popularited after onchange
Hello I have two text inputs which get their values from a datepicker. What
Hello i have two columns: duration (int) and dateCol (date) in a table. How
Hello I have two project in a .NET 4.0 framework visual studio solution. First
I have two types of strings, hello and helloThere . What I want is

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.