@@ -45,7 +45,7 @@ @implementation FTServerHomeViewController
45
45
- (void )loadData {
46
46
if (!_serverObject) {
47
47
_isDataAvailable = NO ;
48
- self. searchBar .text = @" " ;
48
+ _searchBar .text = @" " ;
49
49
50
50
_serverObject = [[FTAPIServerDataObject alloc ] init ];
51
51
if (_selectedView) {
@@ -70,8 +70,8 @@ - (void)loadData {
70
70
}
71
71
}
72
72
else {
73
- if (dAccountsManager .selectedAccount .accountType == FTAccountTypeKeychain) {
74
- [dAccountsManager updateAccount: dAccountsManager .selectedAccount];
73
+ if ([FTAccountsManager sharedManager ] .selectedAccount .accountType == FTAccountTypeKeychain) {
74
+ [[FTAccountsManager sharedManager ] updateAccount: [FTAccountsManager sharedManager ] .selectedAccount];
75
75
}
76
76
[_overviewCell setJobsStats: _serverObject.jobsStats];
77
77
if (_serverObject.jobs .count > 0 ) {
@@ -84,9 +84,9 @@ - (void)loadData {
84
84
_views = _serverObject.views ;
85
85
}
86
86
87
- self. jobs = [NSArray arrayWithArray: _serverObject.jobs];
87
+ _jobs = [NSArray arrayWithArray: _serverObject.jobs];
88
88
[super .tableView reloadData ];
89
- [self setTitle: dAccountsManager .selectedAccount.name];
89
+ [self setTitle: [FTAccountsManager sharedManager ] .selectedAccount.name];
90
90
91
91
if (_serverObject.views .count > 1 ) {
92
92
if (!_selectedView) {
@@ -105,34 +105,19 @@ - (void)loadData {
105
105
}
106
106
}
107
107
108
- #pragma mark Search bar delegate
109
-
110
- - (void )filterSearchResultsWithSearchString : (NSString *)searchString
111
- {
112
- NSMutableArray *arr = [NSMutableArray array ];
113
-
114
- for (FTAPIJobDataObject *job in _serverObject.jobs ) {
115
- NSRange isRange = [job.name rangeOfString: searchString options: NSCaseInsensitiveSearch];
116
- if (isRange.location != NSNotFound ) {
117
- [arr addObject: job];
118
- }
119
- }
120
- self.searchResults = arr;
121
- }
122
-
123
108
#pragma mark Creating elements
124
109
125
110
- (void )createTableView {
126
111
[super createTableView ];
127
112
128
- self. searchBar = [[UISearchBar alloc ] initWithFrame: CGRectMake (0 , 0 , super .tableView.width, 44 )];
113
+ _searchBar = [[UISearchBar alloc ] initWithFrame: CGRectMake (0 , 0 , self .tableView.width, 44 )];
129
114
130
- self. searchController = [[UISearchDisplayController alloc ] initWithSearchBar: self .searchBar contentsController: self ];
131
- self. searchController . searchResultsDataSource = self;
132
- self. searchController . searchResultsDelegate = self;
133
- self. searchController . delegate = self;
115
+ _searchController = [[UISearchDisplayController alloc ] initWithSearchBar: _searchBar contentsController: self ];
116
+ [_searchController setSearchResultsDataSource: self ] ;
117
+ [_searchController setSearchResultsDelegate: self ] ;
118
+ [_searchController setDelegate: self ] ;
134
119
135
- [self .tableView setTableHeaderView: self .searchBar ];
120
+ [self .tableView setTableHeaderView: _searchBar ];
136
121
137
122
_refreshControl = [[UIRefreshControl alloc ] init ];
138
123
[_refreshControl addTarget: self action: @selector (refreshActionCalled: ) forControlEvents: UIControlEventValueChanged];
@@ -182,6 +167,20 @@ - (void)showViewSelector:(UIBarButtonItem *)sender {
182
167
[self presentViewController: nc animated: YES completion: NULL ];
183
168
}
184
169
170
+ #pragma mark Search bar delegate
171
+
172
+ - (void )filterSearchResultsWithSearchString : (NSString *)searchString {
173
+ NSMutableArray *arr = [NSMutableArray array ];
174
+
175
+ for (FTAPIJobDataObject *job in _serverObject.jobs ) {
176
+ NSRange isRange = [job.name rangeOfString: searchString options: NSCaseInsensitiveSearch];
177
+ if (isRange.location != NSNotFound ) {
178
+ [arr addObject: job];
179
+ }
180
+ }
181
+ _searchResults = arr;
182
+ }
183
+
185
184
#pragma mark Table view delegate and data source methods
186
185
187
186
- (NSInteger )numberOfSectionsInTableView : (UITableView *)tableView {
@@ -194,12 +193,12 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
194
193
- (NSInteger )tableView : (UITableView *)tableView numberOfRowsInSection : (NSInteger )section {
195
194
if (tableView == self.tableView ) {
196
195
if ([self isJobsSection: section]) {
197
- return [self .jobs count ];
196
+ return [_jobs count ];
198
197
}
199
198
else return 3 ;
200
199
}
201
200
else {
202
- return [self .searchResults count ];
201
+ return [_searchResults count ];
203
202
}
204
203
}
205
204
@@ -325,7 +324,7 @@ - (FTIconCell *)iconCellForRowAtIndexPath:(NSIndexPath *)indexPath {
325
324
[cell.iconView setDefaultIconIdentifier: @" icon-cogs" ];
326
325
[cell.textLabel setText: FTLangGet (@" Manage Jenkins" )];
327
326
// TODO: Decide if the manage section is only for logged in users!
328
- if ((dAccountsManager .selectedAccount .username && dAccountsManager .selectedAccount .username .length > 0 ) || YES ) {
327
+ if (([FTAccountsManager sharedManager ] .selectedAccount .username && [FTAccountsManager sharedManager ] .selectedAccount .username .length > 0 ) || YES ) {
329
328
[cell setAccessoryType: UITableViewCellAccessoryDisclosureIndicator];
330
329
[cell setSelectionStyle: UITableViewCellSelectionStyleDefault];
331
330
[cell.iconView setAlpha: 1 ];
@@ -355,7 +354,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
355
354
return [self iconCellForRowAtIndexPath: indexPath];
356
355
}
357
356
}
358
- else if ([self .jobs count ] == 0 ) {
357
+ else if ([_jobs count ] == 0 ) {
359
358
return [self cellForNoJob ];
360
359
}
361
360
else {
@@ -463,7 +462,7 @@ - (FTAPIJobDataObject *)jobAtIndexPath:(NSIndexPath *)indexPath inTableView:(UIT
463
462
return nil ;
464
463
}
465
464
466
- NSArray *dataSource = (tableView == self.tableView ? self. jobs : self. searchResults );
465
+ NSArray *dataSource = (tableView == self.tableView ? _jobs : _searchResults );
467
466
NSUInteger dataCount = [dataSource count ];
468
467
469
468
if (dataCount > 0 && indexPath.row < dataCount) {
0 commit comments