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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:15:41+00:00 2026-06-19T03:15:41+00:00

I have a tableview populated by objects loaded from NSUserDefaults. Specifically – when a

  • 0

I have a tableview populated by objects loaded from NSUserDefaults.

Specifically – when a user presses a button in one view controller, a string is loaded into NSUserDefaults, which is then loaded into an array, which finally populates a table view.

I am wondering how I can load an image in each tableview cell, dependent on what string is loaded from NSUserDefaults?

I don’t want to save images IN NSUserDefaults, as I am aware this is not a good idea.

What can I do?

Thank you for your time (and helping a novice out)!


Update 19FEB13

The Strings I am loading into NSUserDefaults are the names of objects, for example “ARCX”.

At the moment I have tried a variety of pieces of code, but I am at the point where I seem to have a misunderstanding/lack of knowledge (or both).

UITableViewCell *XCell = [tableView cellForRowAtIndexPath:IndexPath];
NSString *content = Xcell.textLabel.text;

if ([content isEqualToString:@"ARCX"]) [UIImage *Image = [UIImage imageNamed @"ARCX.png"]];

Obviously I’m getting errors from this code.

I hope you can help!


Update 20FEB13

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
     NSString *string = [myOBJArray objectAtIndex:indexPath.row];
     static NSString *CellIdentifier = @"XCell";
     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
     if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        UIView *cellbackground = [[UIView alloc] initWithFrame:CGRectZero];
        cellbackground.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"MSP cell bg MK2.png"]];
        cell. backgroundView = cellbackground;

}

cell.textLabel.textColor = [UIColor yellowColor ];
cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:24.0];
cell.textLabel.text = string;


 UITableViewCell *XCell = [tableView cellForRowAtIndexPath:indexPath];
 NSString *content = XCell.textLabel.text;

 if ([content isEqualToString:@"ARCX"]) [UIImage *Image = [UIImage imageNamed: @"ARCX.png" ]];


cell.imageView.image = Image;

     return cell;

}

I did have the code I initially posted in the CellForRowAtIndexPath, but I know I am missing something in the implementation (obviously as it doesn’t work!).

Thanks for your time!


Update 19Feb13

I This is my current CellForRowAtIndexPath. No errors, but yet no images in my cells. What am I missing?

Have I got to add an image view? I am currently using a ‘basic’ cell, not a custom one.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *string = [myObjArray objectAtIndex:indexPath.row];
static NSString *CellIdentifier = @"MSCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    UIView *cellbackground = [[UIView alloc] initWithFrame:CGRectZero];
    cellbackground.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"MSP cell bg MK2.png"]];
    cell. backgroundView = cellbackground;
}

cell.textLabel.textColor = [UIColor blackColor ];
cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:24.0];
cell.textLabel.text = string;

if ([string isEqualToString:@"ARCX"])

cell.imageView.image = [UIImage imageNamed: @"ARCX.png"];

else if ([string isEqualToString:@"WPX"])

    cell.imageView.image = [UIImage imageNamed:@"WPX.png"];


 return cell;

}

Thanks for your time!

  • 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-19T03:15:42+00:00Added an answer on June 19, 2026 at 3:15 am
    UITableViewCell *XCell = [tableView cellForRowAtIndexPath:indexPath];
    NSString *content = XCell.textLabel.text;
    

    Please remove this piece of code, as it will call cellForRowAtIndexPath again and again.
    You already have the image name as string

    NSString *string = [myOBJArray objectAtIndex:indexPath.row];
    

    So change the code like below.

    if ([string isEqualToString:@"ARCX"]) 
            UIImage *Image = [UIImage imageNamed: @"ARCX.png"];
    cell.imageView.image = Image;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a TableView with 10 sections that are loaded from a plist file
I have a UITableViewController managing a grouped tableView. The tableView is populated from a
I have a TableView that is populated with data. When a user taps a
I have a tableview where each cell is populated with dynamic data from an
I have a UITableView populated with a mutablearray that is read from NSUserDefaults. I
I have a view-based NSTableView populated custom NSTabelCellView subclass, which are the lowest objects
I have a TableView in a View, and when it scrolls, the rounded part
I have populated a tableview with an array of arrays, but I do not
i have an array of objects which i am populating in a UItable one
I'm trying to delete a row from my table view and so far have

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.