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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:32:45+00:00 2026-06-03T10:32:45+00:00

I have an NSArray that contains a couple of items. The NSArray is loaded

  • 0

I have an NSArray that contains a couple of items. The NSArray is loaded into a uitableview from another class. when I back out of the detail view and re-enter (for the 3rd time), the NSArray is empty and the tableview is empty as well. What is happening? (I am using arc so I don’t think it is a leak)

- (void)viewDidLoad {

    myMatch = [[Match alloc] initWithId:1 OpponentId:13];
}


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

    static NSString *askCellIdent = @"askCell";
    static NSString *answerCellIdent = @"answerCell";


    if (indexPath.row == 0)
    {

        AskCell *cell = [tv dequeueReusableCellWithIdentifier:askCellIdent];
        if (cell==nil) {
            cell = [[AskCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:askCellIdent];
        }

        cell.nameLabel.text = @"Albert asked:";
        cell.questionLabel.text = [NSString stringWithFormat:@"%@", [[myMatch.chat objectAtIndex:indexPath.row] objectAtIndex:1]];
        return cell;
    }
    if (indexPath.row == 1)
    {

        AnswerCell *cell = [tv dequeueReusableCellWithIdentifier:answerCellIdent];
        if (cell==nil) {
            cell = [[AnswerCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:answerCellIdent];
        }

        cell.nameLabel.text = @"Hugh answered:";
        cell.answerLabel.text = [NSString stringWithFormat:@"%@", [[myMatch.chat objectAtIndex:indexPath.row] objectAtIndex:1]];
        return cell;
    }

}

Here is the init code of the my match class:

- (id) initWithId:(NSInteger)yourId OpponentId:(NSInteger)opId {
    self = [super init];
    if (self != nil) {
        //set your id and opponents id to the match.
        [self setUserId:yourId];
        [self setUserId:opId];

        JSON = @"[{\"opponentId\":\"4\",\"chat\":[[\"1\",\"Does he have a beard?\"],[\"1\",\"No.\"]]}]";

        //initiate the chat array.
        chat = [[NSMutableArray alloc] init ];
        [self loadMatch];


    }
    return self;
}

and here is the chat property/synthesize

NSMutableArray *chat;

@property (nonatomic, retain) NSMutableArray *chat;

@synthesize chat;

No idea whats going on, because the slog of the array is empty too!

  • 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-03T10:32:48+00:00Added an answer on June 3, 2026 at 10:32 am

    Declare an int varable repeatCount in appDelegate

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        ypurAppDelegate *appDelegate = (yourAppDelegate *)[[UIApplication sharedApplication]   elegate];
    
    
              appDelegate.repeatCount++;
    
           if(appDelegate.repeatCount %3==0)
           {
               [array removeAllObjects];
                [tableview reloaddata];
            }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have NSArray and I want to remove duplicates from it. I know that
Here is the code that I have for my cell of my UITableView: forKeys:[NSArray
I have an NSArray that contains two types of objects. Lets call them Apple
I have an NSArray which contains NSDictionary objects with keys that are NSNumber objects.
I have a class that conforms to UISearchDisplayDelegate and contains a UISearchBar. This view
I have an NSArray that contains date strings (i.e. NSString) like this: Thu, 21
I have an NSArray which contains 10 objects from index 0 - 9. Each
I have NSArray that contains NSDictionaries. I need to convert it to CFMutableArray that
I have an NSArray that contains nested NSArrays. Im looking for a way to
I have in my App Delegate an NSArray that contains a range of LPProduct

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.