I have NSMutableArray “day” which contain (6 NSMutable arrays) arrays contain
class Lesson{
NSString *time1;
NSString *time2;
NSString *predmet;
NSString *namPrepod;
NSString *zamet;
}
I have function to get current week, day, lesson
-(Lesson *)lessonInWeek:(int)week inDay:(int)day lessonNumber:(int)lNumber
{
Week *currentWeek = nil;
if(week)
currentWeek = nechetNedel;
else
currentWeek = chetNedel;
NSMutableArray *dayArray = [currentWeek.days objectAtIndex:day];
Lesson *lesson = [dayArray objectAtIndex:lNumber];
return lesson;
}
with this function I show in
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
......
Lesson *item = [[Singleton sharedInstance] lessonInWeek:segmentedControl.selectedSegmentIndex inDay:indexPath.section lessonNumber:indexPath.row];
....
time1.text= item.time1;
....
time2.text= item.time2;
....
predmet.text=item.predmet;
.....
namePrepod.text=item.namPrepod;
......
zamet.text=item.zamet;
....
who can I delete a row with this function without the use of ?
if(segmentedControl.selectedSegmentIndex==0)
if(section==1)
......
The function need to edit for delete a row.
Add a
deleteLessonInWeek:inDay:lessonNumber:to your singleton class, and call it from yourtableView:commitEditingStyle:forRowAtIndexPath:implementation:The implementation iside the
Singletoncould use the same clean pattern of looking up day array, then the lesson inside its day, and then deleting the requested item: