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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:13:09+00:00 2026-05-30T23:13:09+00:00

I have my array: self.colorNames = [[NSArray alloc] initWithObjects:@Red, @Green, @Blue, @Indigo, @Violet, nil];

  • 0

I have my array:

self.colorNames = [[NSArray alloc] 
initWithObjects:@"Red", @"Green",
@"Blue", @"Indigo", @"Violet", nil];

I’ve tried everything I can find, but there’s always errors. I want to be able to swipe so that the delete button appears, and then press the delete button and have that row removed.

Full code (everything relating to the table):

// HEADER FILE
@interface ViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {

  IBOutlet UITableView *tableView;
    NSMutableArray *colorNames;

}
@property (strong, nonatomic) NSArray *colorNames;


@end

// IMPLEMENTATION

#import "ViewController.h"

@implementation ViewController

@synthesize colorNames; 

- (void)viewDidLoad {

    [super viewDidLoad];

    self.colorNames = [[NSMutableArray alloc] 
    initWithObjects:@"Red", @"Green",
    @"Blue", @"Indigo", @"Violet", nil];

    [super viewDidLoad];
    //[tableView setEditing:YES animated:NO];
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
 }

// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView  numberOfRowsInSection:(NSInteger)section {
    int count = [colorNames count];
    return count;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

}  

 // Customize the appearance of table view cells.
 - (UITableViewCell *)tableView:(UITableView *)tableView 
 cellForRowAtIndexPath:(NSIndexPath *)indexPath {

 static NSString *CellIdentifier = @"Cell";

 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

 if (cell == nil) {
     cell = [[UITableViewCell alloc]
             initWithStyle:UITableViewCellStyleDefault
             reuseIdentifier:CellIdentifier];

 }
     // Configure the cell.
     cell.textLabel.text = [self.colorNames objectAtIndex: [indexPath row]];

 return cell;

 }
  • 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-30T23:13:10+00:00Added an answer on May 30, 2026 at 11:13 pm

    You have to implement the necessary UITableViewDelegate and UITableViewDataSource methods.

    First, add this:

    - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
        return YES;
    }
    

    Then:

    - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
        if (editingStyle == UITableViewCellEditingStyleDelete) {
            //remove the deleted object from your data source.
            //If your data source is an NSMutableArray, do this
            [self.dataArray removeObjectAtIndex:indexPath.row];
            [tableView reloadData]; // tell table to refresh now
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a method: -(NSArray *)doSomething{ NSArray *array = [[NSArray alloc] initWithObjects:@Huy 1,@Huy 2,@Huy
I have a NSArray with NSIndexPaths inside of it NSArray *array = [self.tableView indexPathsForSelectedRows];
I have an array like this: self.youtubeVideos = [NSArray arrayWithObjects: @http://example.com/index.php?number=1&keyword=, @http://example.com/index.php?number=2&keyword=, nil]; I
I have a MANY_MANY relation: 'rel'=>array(self::MANY_MANY, 'MyClass','table(id_1,id_2)', 'condition'=>'some condiotions AND field_name=:param') I get the
I have two arrays: Parents: Array ( [0] => Levi Self [2] => Portraits
I have array of select tag. <select id='uniqueID' name=status> <option value=1>Present</option> <option value=2>Absent</option> </select>
I have array like this: $path = array ( [0] => site\projects\terrace_and_balcony\mexico.jpg [1] =>
if i have array array[0] = jack; array[1] = jill; array[2] = lisa; array[2]
An array is defined of assumed elements like I have array like String[] strArray
Let's say I have array of bytes: byte[] arr = new byte[] { 0,

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.