Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-28-2011, 09:41 AM   #1 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 13
lll3mk4 is on a distinguished road
Default Looping with NSmutableArray HELP

Hello guys! I need some noob simple help with looping a list of commands.

[textfield1 resignFirstResponder]
[textfield2 resignFirstResponder]
[textfield3 resignFirstResponder]
[textfield4 resignFirstResponder]
[textfield5 resignFirstResponder]

I would really appreciate information on what a have to do in the .h and .m files.
lll3mk4 is offline   Reply With Quote
Old 02-28-2011, 09:45 AM   #2 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 651
kapps11 is on a distinguished road
Default

you can use a for loop:

Code:
for (UITextField *textField in myArray) {
[textField resignFirstResponder];
}
kapps11 is offline   Reply With Quote
Old 02-28-2011, 09:46 AM   #3 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 84
BrendanF is on a distinguished road
Default

Quote:
Originally Posted by lll3mk4 View Post
Hello guys! I need some noob simple help with looping a list of commands.

[textfield1 resignFirstResponder]
[textfield2 resignFirstResponder]
[textfield3 resignFirstResponder]
[textfield4 resignFirstResponder]
[textfield5 resignFirstResponder]

I would really appreciate information on what a have to do in the .h and .m files.

I do not really understand the question since I do not see a NSMutableArray. You could add each of the textfields into an NSMutableArray and then loop through the array and resign for each.

See the NSMutableArray Class Reference
BrendanF is offline   Reply With Quote
Old 02-28-2011, 10:04 AM   #4 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 13
lll3mk4 is on a distinguished road
Default

Quote:
Originally Posted by BrendanF View Post
I do not really understand the question since I do not see a NSMutableArray. You could add each of the textfields into an NSMutableArray and then loop through the array and resign for each.

See the NSMutableArray Class Reference
Well im trying to not have to write every textfield out. Because i have over 20 textfields.
lll3mk4 is offline   Reply With Quote
Old 02-28-2011, 11:03 AM   #5 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 1,106
Meredi86 is on a distinguished road
Default

You still are not that clear about what you want. What do you mean when you say you dont want to have to write every textfield out? Surely the end user will need to write in very textfield? Plus the code you have posted so far is to remove the keyboard from a textfield when the user is done. this you wouldnt need to loop, as the keyboard will go after each textfield
Meredi86 is offline   Reply With Quote
Old 02-28-2011, 02:01 PM   #6 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 84
BrendanF is on a distinguished road
Default

You can just modify the following function to do what you wish:

Code:
-(BOOL)textFieldShouldReturn:(UITextField*)theTextField {
   [theTextField resignFirstResponder];

  return YES;
}
BrendanF is offline   Reply With Quote
Old 02-28-2011, 02:34 PM   #7 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 651
kapps11 is on a distinguished road
Default

he wants to loop through every item in the array and call a method on it, which the code that i posted will do perfectly. However, the deleget method probably makes more sense since only one thing can be firstResponder at a time...
kapps11 is offline   Reply With Quote
Reply

Bookmarks

Tags
nsmutablearray

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 365
18 members and 347 guests
Absentia, akphyo, apatsufas, BinHex, cpsclicker, dre, Error404, Gaz, gmarro, jeroenkeij, Kirkout, MarkC, mottdog, Music Man, PavelMik, teebee74, whitey99, Wikiboo
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,666
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, cpsclicker
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:17 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0