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

  • Home
  • SEARCH
  • 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 1033731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:16:33+00:00 2026-05-16T14:16:33+00:00

HI @ll! I want to add and remove some items to my datasource for

  • 0

HI @ll!

I want to add and remove some items to my datasource for my tableview programmatically.

First of all: What do I want to achieve?
I habe a UIView with a TTTableView control (the Tableview from the Three20 project, but derived from the common UITableView control). This TableView is working well and has a TTSegmentedDataSource object attached as datasource. Currently the TableView is showing a UISwitch component. What I want to do is, to show and hide some items above the UISwitch control according to the state of the switch. And the elements should hide and show using the common TableView animations, just like the user has added or removed an item.

I already tried severeal aproaches to do so, but I don’t get it.

For example:

[self.treeView beginUpdates];
[[((TTSegmentedDataSource*)self.treeView.datasource).items objectAtIndex:0] removeObject: objectToBeRemoved];
[self.treeView endUpdates];
[self.treeView reloadData];

This didn’t work, and also throwed an exception.

What is the solution? How can I programmatically add and remove items from a TableView?

Hoping you can help me! THX!

C YA

  • 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-16T14:16:33+00:00Added an answer on May 16, 2026 at 2:16 pm

    Thanks for your hint cooltechnomax.

    I found the solution. Here is an example:

    [states removeObjectAtIndex:4]; // Washington
    [states removeObjectAtIndex:2]; // Delaware
    
    [states insertObject:@"Alaska" atIndex:0];
    [states insertObject:@"Georgia" atIndex:3];
    [states insertObject:@"Virginia" atIndex:5];
    
    NSArray *deleteIndexPaths = [NSArray arrayWithObjects:
                                [NSIndexPath indexPathForRow:2 inSection:0],
                                [NSIndexPath indexPathForRow:4 inSection:0],
                                nil];
    
    NSArray *insertIndexPaths = [NSArray arrayWithObjects:
                                [NSIndexPath indexPathForRow:0 inSection:0],
                                [NSIndexPath indexPathForRow:3 inSection:0],
                                [NSIndexPath indexPathForRow:5 inSection:0],
                                nil];
    
    UITableView *tv = (UITableView *)self.view;
    
    [tv beginUpdates];
    
    [tv insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationRight];
    [tv deleteRowsAtIndexPaths:deleteIndexPaths withRowAnimation:UITableViewRowAnimationFade];
    
    [tv endUpdates];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to remove a UIView from a superview and add it again at
In c#, when I want to remove some items from a list, i do
I'm trying to add and remove some rows from a table using Jquery. But
I have created a cache using the MemoryCache class. I add some items to
I have dbml with single table users i want add partial class for User
I want to add a column to an existing legacy database and write a
I want to add a constant value onto an incoming bound integer. In fact
I want to add a scheduled task to a client's ASP.NET app. These posts
I want to add a mailto link on our web page. I want to
I want to add a property to my User model that returns the number

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.