Guest User

Untitled

a guest
Dec 14th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. NSMutableArray *mutableTFs = [[NSMutableArray alloc] init];
  2.  
  3. for (UIView *view in [self.view subviews]) {
  4. if ([view isKindOfClass:[UITextField class]]) {
  5. [mutableTFs addObject:view];
  6. }
  7. }
  8.  
  9. NSMutableArray *mutableTFs = [[NSMutableArray alloc] init];
  10.  
  11. for (UITextField *textField in [self.view subviews]) {
  12. [mutableTFs addObject:textField];
  13. }
  14.  
  15. for (UIView *view in [self.view subviews]) {
  16. if ([view isKindOfClass:[UITextField class]]) {
  17. // you don't need to cast just to add to the array
  18. [mutableTFs addObject:view];
  19. // typecasting works as it does in C
  20. UITextField *textField = (UITextField *)view;
  21. // do something with textField
  22. }
  23. }
  24.  
  25. for (UITextField *textField in [self.view subviews]) {
  26. if ([textField isKindOfClass:[UITextField class]]) {
  27. [mutableTFs addObject:textField];
  28. }
  29. }
  30.  
  31. for (UIView *view in [self.view subviews]) {
  32. if ([view isKindOfClass:[UITextField class]]) {
  33. UITextField *textField = (UITextField *)view;
  34. // Do whatever you want with the text field.
  35. }
  36. if ([view isKindOfClass:[UITextView class]]) {
  37. UITextView *textView = (UITextView *)view;
  38. // Do whatever you want with the text view.
  39. }
  40. }
  41.  
  42. // Make sure you're releasing this!
  43. NSMutableArray *textFields = [[NSMutableArray alloc] init];
  44.  
  45. for (UITextField *textField in [self.view subviews]) {
  46. if ([textField isKindOfClass:[UITextField class]]) {
  47. [textFields addObject:textField];
  48. }
  49. }
Add Comment
Please, Sign In to add comment