Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NSMutableArray *mutableTFs = [[NSMutableArray alloc] init];
- for (UIView *view in [self.view subviews]) {
- if ([view isKindOfClass:[UITextField class]]) {
- [mutableTFs addObject:view];
- }
- }
- NSMutableArray *mutableTFs = [[NSMutableArray alloc] init];
- for (UITextField *textField in [self.view subviews]) {
- [mutableTFs addObject:textField];
- }
- for (UIView *view in [self.view subviews]) {
- if ([view isKindOfClass:[UITextField class]]) {
- // you don't need to cast just to add to the array
- [mutableTFs addObject:view];
- // typecasting works as it does in C
- UITextField *textField = (UITextField *)view;
- // do something with textField
- }
- }
- for (UITextField *textField in [self.view subviews]) {
- if ([textField isKindOfClass:[UITextField class]]) {
- [mutableTFs addObject:textField];
- }
- }
- for (UIView *view in [self.view subviews]) {
- if ([view isKindOfClass:[UITextField class]]) {
- UITextField *textField = (UITextField *)view;
- // Do whatever you want with the text field.
- }
- if ([view isKindOfClass:[UITextView class]]) {
- UITextView *textView = (UITextView *)view;
- // Do whatever you want with the text view.
- }
- }
- // Make sure you're releasing this!
- NSMutableArray *textFields = [[NSMutableArray alloc] init];
- for (UITextField *textField in [self.view subviews]) {
- if ([textField isKindOfClass:[UITextField class]]) {
- [textFields addObject:textField];
- }
- }
Add Comment
Please, Sign In to add comment