Content is not displaying in UITableView [closed] - ios

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I am trying to display content in my UITableView in my UIViewController.
My table view is in a regular view called todayView which is in a UIViewController called Calendar
I connected the datasource and delegate to Calendar and added all of the methods for table view, but it still doesn't work.
Currently, my code looks like this
Is there anything I am doing wrong?
#implementation SecondViewController {
NSMutableArray *tableData;
}
-(BOOL)prefersStatusBarHidden{
return YES;
}
- (void)viewDidLoad {
[super viewDidLoad];
NSDate *today = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:#"MMMM dd, yyyy"];
NSString *dateString = [dateFormatter stringFromDate:today];
self.dateLabel.text = dateString;
Event *e1 = [[Event alloc] init];
e1.name = #"All School Mass";
e1.time = #"All Day";
[tableData addObject:e1];
Event *e2 = [[Event alloc] init];
e2.name = #"Tennis - Moreau Catholic vs James Logan";
e2.time = #"4:00 pm at Moreau Catholic";
[tableData addObject:e2];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [tableData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"CellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if(cell == nil)
{
//Create your cell
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
//Configure your cell
Event *event = [tableData objectAtIndex:indexPath.row];
cell.textLabel.text = event.name;
return cell;
}

Have you initialized that tableData mutable Array ?
i think you hav'nt initialized it thats why its all happening.
Please allocate it
tableData= [NSMutableArray array];
than add some objects .
otherwise tableData.count will return always zero.
so no data will be display.

You may forget this method
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
you can implement it and return 1.

Related

[__NSArrayI objectAtIndex:]: message sent to deallocated instance 0x7fbdae1a2080

In tableView I have a few objects that are showing up just fine. However when I interact with the list and scroll down (forward) the app will crash. I have never seen this before and am not aware of why this is happening. I am using a 3rd party calendar in combination with my code, I figured I should mention this but I do not see this being the main issue.
#import "VRGViewController.h"
#interface VRGViewController ()
#end
#implementation VRGViewController{
NSArray *calendarTableData;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
VRGCalendarView *calendar = [[VRGCalendarView alloc] init];
calendar.delegate=self;
calendar.center = self.view.center;
[self.view addSubview:calendar];
calendarTableData = [NSArray arrayWithObjects:#"Egg Benedict", #"Mushroom Risotto",nil];
}
-(void)calendarView:(VRGCalendarView *)calendarView switchedToMonth:(int)month targetHeight:(float)targetHeight animated:(BOOL)animated {
if (month==[[NSDate date] month]) {
NSArray *dates = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],[NSNumber numberWithInt:5], nil];
[calendarView markDates:dates];
}
}
-(void)calendarView:(VRGCalendarView *)calendarView dateSelected:(NSDate *)date {
NSLog(#"Selected date = %#",date);
}
#pragma mark - User Defined Methods
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [calendarTableData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *simpleTableIdentifier = #"Services";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text = [calendarTableData objectAtIndex:indexPath.row];
return cell;
}
#end
You have to declare your datasource the following way:
calendarTableData = [[NSArray alloc]initWithObjects:#"Egg Benedict",
#"Mushroom Risotto",nil];
The issue was coming from how I was calling my array.
Since I was using 3rd party code I had disable ARC. Which was causing my issue with how I was calling my array of objects. Thank you to #meda for helping provide me with the answer - after I implemented it I then realized where I was wrong

How to insert an value into a NSMutableArray? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
I know that my question sounds stupid, but it doesn't work with my code:
#import "TermineViewController.h"
#import "DetailViewController.h"
#interface TermineViewController ()
#end
#implementation TermineViewController {
NSArray *tableData;
int i;
NSString *userid;
NSString *selection;
NSMutableArray *userids;
}
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL *url = [[NSURL alloc] initWithString: #"http://example.com"];
NSString *dataString = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
tableData = [dataString componentsSeparatedByString:#"--"];
NSLog(userids);
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return ([tableData count])/4;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.contentView.backgroundColor = [UIColor blackColor];
cell.accessoryView.backgroundColor = [UIColor blackColor];
[self.tableView setSeparatorColor:[UIColor whiteColor]];
self.view.backgroundColor = [UIColor blackColor];
//Declare all Labels
UILabel *name = (UILabel *)[cell viewWithTag:100];
UILabel *service = (UILabel *)[cell viewWithTag:200];
UILabel *time = (UILabel *)[cell viewWithTag:300];
//Write into Labels and add one to int i (declared in implementation)
name.text = [tableData objectAtIndex:i];
i++;
service.text = [tableData objectAtIndex:i];
i++;
time.text = [tableData objectAtIndex:i];
i++;
userid = [tableData objectAtIndex:i];
NSString *usrid = [NSString stringWithFormat:#"%#", userid];
[userids addObject:usrid];
i++;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
selection = userids[indexPath.row];
NSLog(#"User selected %#", selection);
NSLog(userids[0]);
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:#"details"]) {
DetailViewController *destViewController = (DetailViewController *)[segue destinationViewController];
destViewController.userid = selection;
}
}
#end
So, here are two issues: the first is that I don't get any values in my NSMutableArray (btw it is declared in the #implementation). The second is that I get following error message if the user scrolls in the TableView:
Terminating app due to uncaught exception 'NSRangeException', reason:
'* -[__NSArrayM objectAtIndex:]: index 20 beyond bounds [0 .. 19]'
* First throw call stack: [...]
I don't know whats the matter? Yes, in my Array are 20 values, but the 20th exists!
Thank you very much!!!!
Greetings, Kitzng
You're not creating the array anywhere, you have to do userids = [[NSMutableArray alloc] init] before you can use it.
In your code, i is not defined. My guess is that you mean indexPath.row or indexPath.section. If there are no values in your array, the issue may be that you haven't initialized it when you start adding the objects, and then call something like
tableData = [[NSMutableArray alloc] initWithCapacity:20]
but that's purely speculation based off of the details provided.
As far as the tableView scroll issue, if your array contains 20 objects, indexes [0...19] are the objects. If the table view, in numberOfRowsInSection: is returning something like tableData.count + 1, there will be not data at the index for the last row.

Making the Subtitle in a Table View a time stamp (Objective C) [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I am working on an educational task manager and I am wanting to add a Time stamp to the subtitle section of the cell. I have coded the title of the task correctly but I want to replace subtitle with a time stamp of when the task was created.
I would like to turn where it says Subtitle into a time stamp
Could somebody please help me? Just comment below with the code that I need to add to the Controllers attached to this TableView. Below is my ViewController.h
#import <UIKit/UIKit.h>
#interface ViewController : UIViewController <UITableViewDataSource>
-(IBAction)add:(UIBarButtonItem *)sender;
#property (nonatomic, strong) NSMutableArray *tasksArray;
#property (nonatomic, strong) IBOutlet UITableView *tasksTable;
#end
and this is my ViewController.m
#interface ViewController ()
#end
#implementation ViewController
#synthesize tasksArray = _tasksArray;
#synthesize tasksTable = _tasksTable;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSLog(#"Test");
self.tasksArray = [[NSMutableArray alloc]init];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(IBAction)add:(UIBarButtonItem *)sender
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Enter the task name" message:nil delegate:self cancelButtonTitle:#"Cancel" otherButtonTitles:#"Add", nil];
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
[alert show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *buttonTile = [alertView buttonTitleAtIndex:buttonIndex];
if ([buttonTile isEqualToString:#"Add"]) {
[self.tasksArray addObject:[alertView textFieldAtIndex:0].text];
[self.tasksTable reloadData];
}
}
#pragma mark
#pragma table view
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.tasksArray.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [self.tasksArray objectAtIndex:indexPath.row];
return cell;
}
#end
I am new to StackOverFlow, so don't judge my post if it sucks :p haha! Cheers and please help me!
To create your data array:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *buttonTile = [alertView buttonTitleAtIndex:buttonIndex];
if ([buttonTile isEqualToString:#"Add"]) {
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
[dictionary setObject:[alertView textFieldAtIndex:0].text forKey:#"text"];
[dictionary setObject:[NSDate date] forKey:#"date"];
[self.taskArray addObject:dictionary];
[self.tasksTable reloadData];
}
}
In your cellForRow
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
NSDictionary *currentDictionary = [self.taskArray objectAtIndex:indexPath.row];
cell.textLabel.text = [currentDictionary objectForKey:#"text"];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:#"MM/dd/yyyy HH:mm:ss"];
NSString *dateString = [dateFormat stringFromDate:[currentDictionary objectForKey:#"date"]];
cell.detailTextLabel.text = dateString;
return cell;
}
You can see the date formatter values here

NSMutableArray and NSMutableDictionary in a TableView

I have a problem with using an NSMutableArray and NSMutableDictionary.
I've created a quiz that when it stops, it should display the current score and date in a tableview. It should then display those values in a tableview. But nothing is displayed in the tableview when I load its viewController. The mutableArray is created in the viewDidLoad: method. Is my code correct, or am I missing something here?
- (IBAction)saveResult:(id)sender {
dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:NSLocalizedString(#"DATE", nil)];// #"HH:mm zz"];
dateNow = [NSDate date];
NSString *formattedDateString = [dateFormatter stringFromDate:dateNow];
// Add the quiz result to the array, reload the data in the tableview
highscoreAndDate = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[NSString stringWithFormat:#"%i points", score], #"kResult",
formattedDateString, #"kDate", nil];
[highscore addObject:highscoreAndDate];
[tableView reloadData];
}
My tableView methods:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [highscore count];
}
- (UITableViewCell *)tableView:(UITableView *)_tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat: #"HH:mm zz"];
cell.detailTextLabel.text = [[highscore objectAtIndex:indexPath.row] objectForKey:#"kResult"];
cell.detailTextLabel.text = [[highscore objectAtIndex:indexPath.row] objectForKey:#"kDate"];
return cell;
}
#Anoop Vaidya.
You got me going on the right track. I put the NSLog statement when the objects are added and it shows that the row count of my array is going up. So my code is correct.
I figured out that it was due to my connections in my XIB file (very embarrassing!). Should have spotted that my self. I had hooked up my tableview outlets to the wrong viewController and so the tableview was never populated.
Very sorry for have taken up your time and thanks to everybody who responded so quickly. Glad I got it fixed. :)

Getting a SIGABRT From Deleting a Row in a Table View

I am trying to have a table view list a number of objects that are stored in an array and it's working fine other than when I try to delete a row, it throws a SIGABRT. I checked at it is correctly updating the array. It seems that the SIGABRT has something to do with the number of sections in the table. Here is the code for the table view controller:
CalendarViewController.h
#import <UIKit/UIKit.h>
#import "Job.h"
#import "Shift.h"
#import "AppDelegate.h"
#interface CalendarViewController : UITableViewController
#property (nonatomic, strong) NSMutableArray *currentShiftsList;
#property (nonatomic, strong) AppDelegate *dataCenter;
#end
CalendarViewController.m
#import "CalendarViewController.h"
#interface CalendarViewController ()
#property (nonatomic, strong) NSMutableDictionary *sections;
#property (nonatomic, strong) NSArray *sortedShifts;
#property (strong, nonatomic) NSDateFormatter *sectionDateFormatter;
#property (strong, nonatomic) NSDateFormatter *cellDateFormatter;
#end
#implementation CalendarViewController
#synthesize sections, sortedShifts, currentShiftsList, dataCenter, sectionDateFormatter, cellDateFormatter;
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (NSDate *)dateAtBeginningOfDayForDate:(NSDate *)inputDate {
// Use the user's current calendar and time zone
NSCalendar *calendar = [NSCalendar currentCalendar];
NSTimeZone *timeZone = [NSTimeZone systemTimeZone];
[calendar setTimeZone:timeZone];
// Selectively convert the date components (year, month, day) of the input date
NSDateComponents *dateComps = [calendar components:NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit fromDate:inputDate];
// Set the time components manually
[dateComps setHour:0];
[dateComps setMinute:0];
[dateComps setSecond:0];
// Convert back
NSDate *beginningOfDay = [calendar dateFromComponents:dateComps];
return beginningOfDay;
}
- (NSDate *)dateByAddingYears:(NSInteger)numberOfYears toDate:(NSDate *)inputDate
{
// Use the user's current calendar
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *dateComps = [[NSDateComponents alloc] init];
[dateComps setYear:numberOfYears];
NSDate *newDate = [calendar dateByAddingComponents:dateComps toDate:inputDate options:0];
return newDate;
}
- (void)viewDidLoad
{
[super viewDidLoad];
dataCenter = (AppDelegate *)[[UIApplication sharedApplication] delegate];
currentShiftsList = [[NSMutableArray alloc] initWithArray:dataCenter.shiftsList];
self.sectionDateFormatter = [[NSDateFormatter alloc] init];
[self.sectionDateFormatter setDateStyle:NSDateFormatterLongStyle];
[self.sectionDateFormatter setTimeStyle:NSDateFormatterNoStyle];
self.cellDateFormatter = [[NSDateFormatter alloc] init];
[self.cellDateFormatter setDateStyle:NSDateFormatterNoStyle];
[self.cellDateFormatter setTimeStyle:NSDateFormatterShortStyle];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
self.navigationItem.rightBarButtonItem = self.editButtonItem;
self.sections = [NSMutableDictionary dictionary];
for (Shift *shift in dataCenter.shiftsList) {
// Reduce event start date to date components (year, month, day)
NSDate *dateRepresentingThisDay = [self dateAtBeginningOfDayForDate:shift.startDate];
// If we don't yet have an array to hold the events for this day, create one
NSMutableArray *shiftsOnThisDay = [self.sections objectForKey:dateRepresentingThisDay];
if (shiftsOnThisDay == nil) {
shiftsOnThisDay = [NSMutableArray array];
// Use the reduced date as dictionary key to later retrieve the event list this day
[self.sections setObject:shiftsOnThisDay forKey:dateRepresentingThisDay];
}
// Add the event to the list for this day
[shiftsOnThisDay addObject:shift];
}
// Create a sorted list of days
NSArray *unsortedShifts = [self.sections allKeys];
self.sortedShifts = [unsortedShifts sortedArrayUsingSelector:#selector(compare:)];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return [self.sections count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
NSDate *dateRepresentingThisDay = [self.sortedShifts objectAtIndex:section];
NSArray *eventsOnThisDay = [self.sections objectForKey:dateRepresentingThisDay];
return [eventsOnThisDay count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *reuseIdentifier = #"shifts";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
NSDate *dateRepresentingThisDay = [self.sortedShifts objectAtIndex:indexPath.section];
NSArray *eventsOnThisDay = [self.sections objectForKey:dateRepresentingThisDay];
Shift *shift = [eventsOnThisDay objectAtIndex:indexPath.row];
cell.textLabel.text = shift.jobtitle;
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:#"h:mm a"];
NSString *start = [formatter stringFromDate:shift.startDate];
NSString *end = [formatter stringFromDate:shift.endDate];
NSString *detail = [[NSString alloc] initWithFormat:#"%# to %#", start, end];
cell.detailTextLabel.text = detail;
return cell;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
NSDate *dateRepresentingThisDay = [self.sortedShifts objectAtIndex:section];
return [self.sectionDateFormatter stringFromDate:dateRepresentingThisDay];
}
/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the specified item to be editable.
return YES;
}
*/
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
[currentShiftsList removeObjectAtIndex:indexPath.row];
dataCenter.shiftsList = currentShiftsList;
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
}
*/
/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the item to be re-orderable.
return YES;
}
*/
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here. Create and push another view controller.
/*
<#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:#"<#Nib name#>" bundle:nil];
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
*/
}
#end
This doesn't make sense to me.
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
Why isn't it just:
[tableView deleteRowsAtIndexPaths:indexPath.row withRowAnimation:UITableViewRowAnimationFade];
Also remember a reload TableView after delete (if you want it).
When you delete a row, you are removing an item from the currentShiftsList array. However, you are not using that array in your UITableViewDataSource related methods. The TableView is expecting there to be 1 less item from its DataSource, but you will be returning the original number of items instead.
Overall, things are very confusing because you have several collections that are trying to manage the same set of data (or copies of that data). Try looking into CoreData and the NSFetchedResultsController which is specifically made to managed a set of data and propagate any changes to a UITableView.

Resources