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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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 12-07-2009, 10:54 AM   #1 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 4
Default array UI objects such as buttons?

Hi.

New to Obj-c.

Is there a way to declare UI objects such as buttons, so that i can access and manipulate them by an index (based on tag) instead of needing unique names for each? I am particularly interested where I want to change a button's titlecolor based on some condition.

Example:

Instead of:
UIButton *btn1, *btn2, *btn3,...*btn10;
...
//Then use corresponding tag for each in code:
-(IBAction) buttonPressedUIButton *)sender
{
switch ([sender tag])
{
case 1: if (btn1 meets some condition)...;break;
case 2: if (btn2 meets some condition)...;break;
case 3: if (btn3 meets some condition)...;break;
...
case 10: if(btn10 meets some condition)...;break;
}
}


...Is it possible to set up multiple instances of btn, i.e., declare btn(10) so that I can do this, where the button's tag is used as an index:

-(IBAction) buttonPressed...
{
if (btn([sender tag]) meets some condition)...;
}

Thanks!
Al
Alferber is offline   Reply With Quote
Old 12-07-2009, 11:58 AM   #2 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 4
Smile Frowny face

BTW: I don't know how that frowny-face got into the middle of my post. User error, I guess. I'm a smiley guy!
Alferber is offline   Reply With Quote
Reply

Bookmarks

Tags
index, uibutton

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: 328
21 members and 307 guests
@sandris, ADY, BrianSlick, dacapo, Dani77, Dattee, dre, HDshot, HemiMG, JasonR, MarkC, mer10, nibeck, prchn4christ, ryandb2, spiderguy84, themathminister, timle8n1, tomtom100, vogueestylee, vvenkatachallam
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,883
Threads: 89,229
Posts: 380,763
Top Poster: BrianSlick (7,129)
Welcome to our newest member, vvenkatachallam
Powered by vBadvanced CMPS v3.1.0

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