daily pastebin goal
38%
SHARE
TWEET

Untitled

a guest Sep 14th, 2018 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (void)viewDidLoad {
  2. [super viewDidLoad];
  3.  
  4. NSMutableArray<Model*>* firstArry = [[NSMutableArray alloc] init];
  5. NSArray<Model*>* secondArry = [[NSMutableArray alloc] init];
  6.  
  7.  
  8. Model* p1 = [[Model alloc] init];
  9. p1.name = @"bob";
  10. p1.lastName = @"bdas";
  11.  
  12. [firstArry addObject:p1];
  13.  
  14. Model* p2 = [[Model alloc] init];
  15. p2.name = @"juny";
  16. p2.lastName = @"his";
  17.  
  18. [firstArry addObject:p2];
  19.  
  20. Model* p3 = [[Model alloc] init];
  21. p3.name = @"junay";
  22. p3.lastName = @"firs";
  23.  
  24. [firstArry addObject:p3];
  25.  
  26. Model* p4 = [[Model alloc] init];
  27. p4.name = @"bobov";
  28. p4.lastName = @"daskal";
  29.  
  30. [firstArry addObject:p4];
  31.  
  32. Model* p5 = [[Model alloc] init];
  33. p5.name = @"dima";
  34. p5.lastName = @"bonder";
  35.  
  36. [firstArry addObject:p5];
  37.  
  38. for (Model* name in firstArry){
  39.     NSLog(@"%@",name.name);
  40. }
  41.  
  42. NSString* filterWord = @"bo";
  43.  
  44. NSPredicate* predicate = [NSPredicate predicateWithFormat:@"keywords.name CONTAINS[cd] %@",filterWord];
  45. secondArry = [firstArry filteredArrayUsingPredicate:predicate];
  46.  
  47.  
  48. if(secondArry.count > 0){
  49. for (Model* name in firstArry){
  50.     NSLog(@"%@",name.name);
  51. }
  52. } else {
  53.     NSLog(@"second arry is empty");
  54. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top