-
Notifications
You must be signed in to change notification settings - Fork 0
/
TrackViewController.m
89 lines (72 loc) · 2.82 KB
/
TrackViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//
// Track.m
// VoiceProject
//
// Created by trainee on 8/24/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import "TrackViewController.h"
#import "XTableController.h"
#import "MainViewController.h"
#import "TrackEditViewController.h"
@interface TrackViewController ()
@property (retain, nonatomic) XTableController *xcontroller;
@property (retain, nonatomic) IBOutlet UITableView *tableOfTracks;
@property (retain, nonatomic) NSString *nameOfcell;
@end
@implementation TrackViewController
NSString *const keyForNotificationRenameTrack = @"reloadTableOfTrack";
@synthesize xcontroller;
@synthesize tableOfTracks;
@synthesize nameOfcell;
@synthesize groupName;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad {
XTableController *controller = [[XTableController alloc]
initWithGroupName:self.groupName];
self.xcontroller = controller;
[controller release];
//create table of tracks
[self.tableOfTracks setDelegate: self];
[self.tableOfTracks setDataSource: self.xcontroller];
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(reloadTableOfTrack:)
name:keyForNotificationRenameTrack
object:nil];
}
- (void)reloadTableOfTrack:(NSNotification *)notification {
[self.xcontroller reloadTracks];
[self.tableOfTracks reloadData];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"TrackEditViewControllerSegue"]) {
TrackEditViewController *trackEditViewController = [segue destinationViewController];
trackEditViewController.nameOfTrackButton = sender;
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
self.nameOfcell = cell.textLabel.text;
[self performSegueWithIdentifier:@"TrackEditViewControllerSegue" sender:cell.textLabel.text];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
- (void)viewDidUnload {
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self name:keyForNotificationRenameTrack object:nil];
[tableOfTracks release];
[super dealloc];
}
@end