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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:30:30+00:00 2026-06-06T07:30:30+00:00

I have a program where a UITableView contains custom cells loaded from nibs. These

  • 0

I have a program where a UITableView contains custom cells loaded from nibs. These cells have textfields and a UIImage. I’ve been passing the information they contain to a custom class and encoding/decoding the class for data persistence. When I want to load the data, I put the information from the class into the cell. This works fine for 1 cell, but not for more than one. I’ve checked, and the classes are being written to file correctly.

This is my retrieval method:

//Fills an array if the file exists, otherwise returns nil
- (NSMutableArray*) findFile: (NSString *) add
{
    if ([[NSFileManager defaultManager] fileExistsAtPath:[self saveFilePath:add]])
    {
        NSString *temp = [add stringByAppendingString:@"dat"];
        namesIndexer = [[NSMutableArray alloc] initWithContentsOfFile:[self saveFilePath:temp]];

        if (namesIndexer == nil) return nil;

        NSMutableArray *thing = [NSMutableArray new];
        for (NSString *place in namesIndexer)
        {
            temp = [add stringByAppendingString:place];
            PTextHolder *p = [NSKeyedUnarchiver unarchiveObjectWithFile:[self saveFilePath:temp]];
            [thing addObject:p];
        }
        return thing;
    }
    else 
    {
        return nil;
    }
}

Note that this is in a different class, and it calls the method from the holder.

//Returns a cell to be used at a row, populates it from the holder object
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{   
    static NSString *personCellId = @"personID";
    UINib *nib = [UINib nibWithNibName:@"PersonCell" bundle:nil];
    [tableView registerNib:nib forCellReuseIdentifier:personCellId];
    PersonCell *cell = [tableView dequeueReusableCellWithIdentifier:personCellId];

    cell.owner = tableView;
    if (mineTable == nil) mineTable = tableView;
    cell.delegated = formDataStorage;

    [formDataStorage putWhatShouldBeInThisCellForThisRowInIt:cell:(int*)indexPath.row];

    cell.currentRow = [[NSNumber alloc] initWithInt:indexPath.row];

    return cell;
}

Here’s the method it calls:

- (void) putWhatShouldBeInThisCellForThisRowInIt: (PersonCell *) someCell: (int *) someRow
{
    if ((NSUInteger) someRow >= cake.count)
    {
        NSLog(@"The cake has been undercooked");
        return;
    }

    PTextHolder *temp = [cake objectAtIndex:(NSUInteger) someRow];

    someCell.firstName.text = temp.first;
    someCell.lastName.text = temp.last;
    someCell.middleName.text = temp.middle;
    someCell.suffixName.text = temp.suffix;
    someCell.email.text = temp.email;
    someCell.theSignature.image = temp.sig;
}

Anything look wrong here/would cause only one cell to be loaded?

  • 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-06T07:30:32+00:00Added an answer on June 6, 2026 at 7:30 am

    I would check first the number of items in the array with

    [array count]

    , if the number of items is equal to 1, then the problem is as you guessed with the encoding/decoding.

    If not, your code is right and the problem is with your code to load the cells.

    By the way, why dont you store your array of “cellInfoClass” directly using:

    [NSKeyedArchiver archiveRootObject:array toFile:filePath]

    and retrieve directly the array.

    I guess you already added the encoding/coding code to your class, if not is like that:

    /**  
     * Returns an object initialized from data in a given unarchiver. (required)  
     *  
     * @param decoder: An unarchiver object.  
     */
    - (id)initWithCoder:(NSCoder *)coder {
        if (self = [super init]) {      
        // If parent class also adopts NSCoding, replace [super init]
        // with [super initWithCoder:decoder] to properly initialize.       
           [self setName:[coder decodeObjectForKey:@"name"]];       
           [self setId:[coder decodeIntForKey:@"id"]];      
           [self setDomain:[coder decodeObjectForKey:@"domain"]];   
        }
        return self;     
     }
    
    
    /**  
     * Encodes the receiver using a given archiver. (required) 
     * @param coder: An archiver object.  
     */
    - (void)encodeWithCoder:(NSCoder *)coder{
        // If parent class also adopts NSCoding, include a call to
        // [super encodeWithCoder:encoder] as the first statement.  
        [coder encodeObject:name forKey:@"name"];
        [coder encodeInt:id forKey:@"id"];
        [coder encodeObject:domain forKey:@"domain"];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry I'm pretty new to iOS dev. I have a UITableView setup from cells
I have the following program structure: -(UITableViewCell *)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { ... ... if(cell
I have a program that reads approximately 2million rows from a database into a
i have program which prints all char from char_min to char_max here is code
I have an UITableView and I want to populate it with data from this
I have program that the number of classes loaded there is constantly rising. How
I have used custom cell class for my uitableview and used in cellForRowAtIndexPath method.
I have program written with R. I can run it from the R GUI
I have program that sends a file to a printer using 'lpr' command. I
I have program, that has structure defined like this: struct foo { int magic;

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.