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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:51:45+00:00 2026-05-30T05:51:45+00:00

I’m having a problem adding an item to my tableView. I used to initialize

  • 0

I’m having a problem adding an item to my tableView.

I used to initialize an empty tableView at the start of my App and get it filled with scanned items every time the tableView reappears and there is an item in my variable.

Initialization of the tableView:

NSMutableArray *array = [[NSMutableArray alloc] initWithObjects:nil];
self.listArray = array;

TableView Data Source:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    return [self.listArray count];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section 
{
    if(section == 0)
        return @"Eingescannte Artikel:";
    else
        return nil;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"testCell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];


    // Configure the cell...
    NSUInteger row = [indexPath row];
    cell.textLabel.text = [listArray objectAtIndex:row];//[NSString stringWithFormat:@"Das ist Zeile %i", indexPath.row];
    return cell;
}

(Not the whole thing but the ones I changed)

As you may have seen I use an NSMutableArray to add items to my tableView.

So if an item ist scanned I’m adding it to my array like this:

[listArray insertObject:sharedGS.strEAN atIndex:0]; //using a shared Instance where I implemented my variable.

I also tried to use an variable to extend my Index every time a new Item is added, but it won’t work both ways.

I’m quite new to programming so an not-too-hard-to-understand-answer would be quite nice 😉

If there’s any information missing, feel free to ask.

/edit: Trying to specify my question: The data from the variable is written in a TableViewCell, but if I scan another one the other one is just being replaced. Not sure if it’s a problem with my array or my tableView…

/edit No.2: Found out(thanks to fzwo) that my array isn’t working correctly. It just doesn’t grow by an addObject: or insertObject:atIndex: command. But I just don’t get why… 🙁
All I’m doing: [listArray addObject:sharedGS.strEAN]; not that much space for errors in one simple line. Maybe I’m just too stupid to recognize what I’m doing wrong:D

  • 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-30T05:51:47+00:00Added an answer on May 30, 2026 at 5:51 am

    You state that your problem is “adding an item to my tableView” , since you are adding the object to your array i am guessing the problem is that you are not reloading the table or that it is missing the dataSource binding.

    You have not actually asked any question (even if you added info to “specify your question”) so a wild guess, after

    [listArray insertObject:sharedGS.strEAN atIndex:0];
    

    put

    [yourTableView reloadData];
    

    Are you intentionally adding new items to the top of the table ? otherwise you could do
    [listArray addObject:sharedGS.strEAN]; to add new items to the bottom

    Otherwise it’s worth noting that you are misusing dequeueReusableCellWithIdentifier, look at the example below for proper usage:

    // Try to retrieve from the table view a now-unused cell with the given identifier
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
    
    // If no cell is available, create a new one using the given identifier
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Specifically, suppose I start with the string string =hello \'i am \' me And
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I am writing an app with both english and french support. The app requests
I am using Paperclip to handle profile photo uploads in my app. They upload

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.