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 03-15-2009, 03:05 AM   #1 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 2
waynechiu is on a distinguished road
Default How to define an array of IBOutlet??

I am trying to define an array of IBOutlet UIButton but it fail.
IBOutlet UIButton *myButton[3];
@property (nonatomic, retain) UIButton **myButton;

are OK. Don't have any compiler error but
@synthesize myButton; give me an error and also I don't see the myButton in the File's Owner of Interface Builder.
waynechiu is offline   Reply With Quote
Old 03-15-2009, 09:08 AM   #2 (permalink)
Senior Member
 
Join Date: Jan 2009
Location: Florida, USA
Posts: 471
Slayer5150 is an unknown quantity at this point
Default

Quote:
Originally Posted by waynechiu View Post
I am trying to define an array of IBOutlet UIButton but it fail.
IBOutlet UIButton *myButton[3];
@property (nonatomic, retain) UIButton **myButton;

are OK. Don't have any compiler error but
@synthesize myButton; give me an error and also I don't see the myButton in the File's Owner of Interface Builder.
I'm not sure if it should work or not, but you would need to synthesize *(myButton), *(myButton+1) and *(myButton+2).
Slayer5150 is offline   Reply With Quote
Old 03-15-2009, 02:58 PM   #3 (permalink)
New Member
 
Join Date: Sep 2008
Posts: 1,431
PhoneyDeveloper is on a distinguished road
Default

You can't really do it that way. Properties don't work with arrays and you can't make the outlet be assigned to an offset into an array. It might be possible to do this with a union but I've never tried that.

If what you want is an array of buttons then use an NSArray and set the tags of the buttons in IB. Then add the buttons to the array based on the tags in viewDidLoad.

Also, if it's really only three buttons then just have three outlets. I don't think that's a big deal.
PhoneyDeveloper is offline   Reply With Quote
Old 03-20-2009, 02:58 AM   #4 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 2
waynechiu is on a distinguished road
Default

Thanks. Will try the NSArray.
waynechiu is offline   Reply With Quote
Old 03-18-2011, 06:32 AM   #5 (permalink)
Mishti
 
Join Date: Mar 2011
Location: Mumbai
Posts: 28
mishti is on a distinguished road
Default

Quote:
Originally Posted by Slayer5150 View Post
I'm not sure if it should work or not, but you would need to synthesize *(myButton), *(myButton+1) and *(myButton+2).
hi
I m new new in iphone world. Plz can u give me knowledge abt, how to use the dynamic array?

thanxxxxxxxxxx
mishti is offline   Reply With Quote
Old 03-18-2011, 10:25 AM   #6 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

I know this is an old thread, but I recently saw a blog post that would be useful:

Using iOS 4′s IBOutletCollection
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Reply

Bookmarks

Tags
array, iboutlet, 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: 334
3 members and 331 guests
guusleijsten, Kryckter, LEARN2MAKE
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,880
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

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