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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:23:51+00:00 2026-05-31T13:23:51+00:00

For my UITableView I use an array as a datasource. Everything works fine so

  • 0

For my UITableView I use an array as a datasource. Everything works fine so far. However, I have the weird issue, that when I use the search field and enter a few characters, which I afterwards delete again, the underlying array is suddenly empty. Here the code snippets, which might be relevant to understand my issue:

Declaration in my .h

@interface dictionaryViewController : UIViewController <UITableViewDelegate>{
...
...
    NSMutableArray *cardArray;

}

...
@property (retain) NSMutableArray *cardArray;
...

Usage in my .m code:

@synthesize cardArray;
...

- (void)viewDidLoad {
[super viewDidLoad];
self.cardArray = [[NSMutableArray alloc] initWithObjects:nil];
...
}

I populate the array with data from my SQL DB:

            [self.cardArray addObject:[NSString stringWithFormat:@"%@ - %@", aQuestion, anAnswer]];

And within the code read the content of the array like in the cellForRow method:

- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
...
thisCardIndex = [self.cardArray indexOfObject:cellValue];
...
}

At the end I release it, like this (I actually had some other issues with the release command, why I used the removeObjects instead):

    [self.cardArray removeAllObjects];
    self.cardArray=nil;

In the log I do not see an error. The debugger shows, however, that the code crashes with a SIGABRT and when setting breakpoints I see, that the cause is the empty cardArray.

Thanks for the support in advance.

  • 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-31T13:23:51+00:00Added an answer on May 31, 2026 at 1:23 pm

    ok, finally found the culprit, it was the [myArray release] (see commented line below). I have no clue, WHY though. This is a local array, which I define locally and also should be able to release immediatly again. And the interesting part is, that this code works as long as the search is narrowing. It only crashes, when the search field is empty again. VERY confusing, but maybe someone has an explanation?? Anyway, finally got it and it ru as expected.

    - (void) searchTableView {
    
    NSString *searchText = searchBar.text;
    NSMutableArray *searchArray = [[NSMutableArray alloc] initWithObjects:nil];
    
    for (NSDictionary *dictionary in self.listOfItems) {
        NSArray *myArray = [dictionary objectForKey:@"Cards"];
        [searchArray addObjectsFromArray:myArray];
    

    // [myArray release];
    }

    // Counter is needed to get the index of the primary key to dislpay the card in editViewController
    int aCounter=0; 
    for (NSString *sTemp in searchArray) {
        NSRange titleResultsRange = [sTemp rangeOfString:searchText options:NSCaseInsensitiveSearch];
    
        if (titleResultsRange.length > 0) {
            [self.aCopyListOfItems addObject:sTemp];
            NSInteger myPrimaryKey;
            myPrimaryKey = [[self.cardIDArray objectAtIndex:aCounter] integerValue];
            [self.aCopyOfCardIDArray addObject:[NSNumber numberWithUnsignedInteger: myPrimaryKey]];
        }
    }
    
    [searchArray removeAllObjects];
    searchArray = nil;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bunch of userdefaults value that I use to load my UITableView
I have a nice working iphone app that works with core data. I use
I have a UITableView cell that is going to have a variable size depending
I have a UITableView which is populated by an array, I have a button
So I have a UITableView which should loop through a single NSMutableArray and use
I have a UITableView subclass and a UITableViewCell subclass that I'm using for cells.
I have a UITableView containing names that I would like to group (and sort)
I have a big problem with an UITableView, I want to use a label
I have an array of dictionaries from a JSON feed. This populates a UITableView
I have created NSMutale Array in HeroListViewController . I want use it in another

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.