Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

newConvert

macrumors regular
Original poster
Aug 25, 2006
214
3
Just a quick (hopefully!) question for some of you more experiance people out there....

In my view I have about 6 textboxes, however, due to the way my app works I do not want to have to create an individual outlet for each one... I was wondering how you go about re-assigning a different textbox to the one outlet you have? Thanks!
 

johnnyjibbs

macrumors 68030
Sep 18, 2003
2,964
122
London, UK
I second that. The quicker you can ween yourself off of Interface Builder the better. It's great when you're starting out, but it soon becomes easy to imagine the layout programmatically. Coding everything is much more flexible.
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
Interface Builder usage is mostly a matter of opinion. Mostly. Some people, like johnnyjibbs, try to avoid it. Others consider it just another tool in their arsenal. Sure, there are some things you can't do with IB but it does have other advantages. If you feel comfortable using it and are working alone, no need to ween yourself off it. If you are working as a team, the team needs to decide whether to keep it or lose it. Hope that helps.
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
Your question is a little vague.

You can use tags to find a subview. Just set the tags in IB for your text fields and then use viewWithTag to find the text field that you want.

If that's not the answer you need to describe the problem better.
 

newConvert

macrumors regular
Original poster
Aug 25, 2006
214
3
Sorry for being unclear, this is what I'm looking for...

Currently, I have 6 textboxes (might be as high as 15-20 in the end) and I'm looking for a way to have just one IBOutlet, and assign it whichever textbox I need to get input to Does that make sense?

IE

IBOutlet UITextfield *onlyOutlet;

Then if a certain variable is 5, I want to assign this outlet to the 5th textbox, just not sure of the syntax? Thanks.
 

eddietr

macrumors 6502a
Oct 29, 2006
807
0
Virginia
So the syntax is simple. It's just:

Code:
onlyOutlet = idOfSomeTextField

the more interesting part will be keeping track of the id's of all the TextFields. You might just keep an array for those. And then create the textfields programatically and keep the id's in your array.

Or if you are using IB, then tag the textfields and look them up that way and put them into an array after the Nib is loaded.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.