@@ -39,16 +39,12 @@ -(void)viewDidLoad {
3939 self.allUsers = [[NSMutableArray alloc ] init ];
4040 [self .myTableView registerNib: [UINib nibWithNibName: kCellIdentifier_ReviewCell bundle: nil ] forCellReuseIdentifier: kCellIdentifier_ReviewCell ];
4141 self.myTableView .separatorStyle = NO ;
42-
43-
4442 [self .myTableView mas_makeConstraints: ^(MASConstraintMaker *make) {
4543 make.edges .equalTo (self.view );
4644 }];
4745 UIEdgeInsets insets = UIEdgeInsetsMake (0 , 0 , 0 , 0 );
4846 self.myTableView .contentInset = insets;
4947 self.myTableView .scrollIndicatorInsets = insets;
50-
51-
5248 _mySearchBar = ({
5349 UISearchBar *searchBar = [[UISearchBar alloc ] init ];
5450 searchBar.delegate = self;
@@ -120,15 +116,6 @@ -(void)updateUnReviewers {
120116 self.allUsers = totalUser;
121117}
122118
123- - (id )initWithFrame : (CGRect)frame projects : (Projects *)projects block : (AddReviewerViewControllerBlock)block tabBarHeight : (CGFloat)tabBarHeight
124- {
125- // self = [super initWithFrame:frame];
126- if (self) {
127- // Initialization code
128-
129- }
130- return self;
131- }
132119#pragma mark Table M
133120
134121- (CGFloat)tableView : (UITableView *)tableView heightForHeaderInSection : (NSInteger )section {
@@ -149,14 +136,11 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
149136
150137- (UITableViewCell *)tableView : (UITableView *)tableView cellForRowAtIndexPath : (NSIndexPath *)indexPath {
151138 ReviewCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_ReviewCell forIndexPath: indexPath];
152-
153- // [cell configureCellWithHeadIconURL:@"test" reviewIconURL:@"PointLikeHead" userName:@"test" userState:@"test"];
154139 User* cellReviewer = self.allUsers [indexPath.row];
155140 cell.accessoryType = UITableViewCellAccessoryNone;
156141 [cell initCellWithUsers: cellReviewer];
157142 [tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: 60 ];
158143 return cell;
159-
160144}
161145
162146- (CGFloat)tableView : (UITableView *)tableView heightForRowAtIndexPath : (NSIndexPath *)indexPath {
@@ -195,32 +179,20 @@ - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{
195179 [self searchProjectWithStr: searchText];
196180}
197181
198-
199182- (void )searchBarSearchButtonClicked : (UISearchBar *)searchBar {
200183 [searchBar resignFirstResponder ];
201184 [self searchProjectWithStr: searchBar.text];
202185}
203186
204187- (void )searchProjectWithStr : (NSString *)searchString {
205- // strip out all the leading and trailing spaces
206188 NSString *strippedStr = [searchString stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceCharacterSet ]];
207-
208- // break up the search terms (separated by spaces)
209189 NSArray *searchItems = nil ;
210- if (strippedStr.length > 0 )
211- {
190+ if (strippedStr.length > 0 ) {
212191 searchItems = [strippedStr componentsSeparatedByString: @" " ];
213192 }
214-
215- // build all the "AND" expressions for each value in the searchString
216193 NSMutableArray *andMatchPredicates = [NSMutableArray array ];
217-
218- for (NSString *searchString in searchItems)
219- {
220- // each searchString creates an OR predicate for: name, global_key
194+ for (NSString *searchString in searchItems) {
221195 NSMutableArray *searchItemsPredicate = [NSMutableArray array ];
222-
223- // name field matching
224196 NSExpression *lhs = [NSExpression expressionForKeyPath: @" name" ];
225197 NSExpression *rhs = [NSExpression expressionForConstantValue: searchString];
226198 NSPredicate *finalPredicate = [NSComparisonPredicate
@@ -230,14 +202,10 @@ - (void)searchProjectWithStr:(NSString *)searchString{
230202 type: NSContainsPredicateOperatorType
231203 options: NSCaseInsensitivePredicateOption];
232204 [searchItemsPredicate addObject: finalPredicate];
233-
234- // at this OR predicate to ourr master AND predicate
235205 NSCompoundPredicate *orMatchPredicates = (NSCompoundPredicate *)[NSCompoundPredicate orPredicateWithSubpredicates: searchItemsPredicate];
236206 [andMatchPredicates addObject: orMatchPredicates];
237207 }
238-
239208 NSCompoundPredicate *finalCompoundPredicate = (NSCompoundPredicate *)[NSCompoundPredicate andPredicateWithSubpredicates: andMatchPredicates];
240-
241209 self.allUsers = [[self .users filteredArrayUsingPredicate: finalCompoundPredicate] mutableCopy ];
242210 [self .myTableView reloadData ];
243211}
0 commit comments