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 09-13-2010, 03:30 AM   #1 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 8
LimJT is on a distinguished road
Question Xcode array help

Greetings developers,

I'm having trouble in my iPhone programming.

I have labels in my project, its names are "label1", "label2", "label3", "label4"...etc

What I would like to do is described below:

while (int i=1; i<10; i++) {
label[i].text = [NSString stringWithFormat:@"%d", i];
}


I couldn't find the solution for this problem. I would appreciate any useful feedbacks!
LimJT is offline   Reply With Quote
Old 09-13-2010, 04:01 AM   #2 (permalink)
Registered Member
 
CambridgeCoders's Avatar
 
Join Date: Jul 2010
Location: Cambridge, UK
Posts: 73
CambridgeCoders is on a distinguished road
Default

Hi,

You would need to create the array yourself first to contain references to the labels. Something like the following (untested!) code:

Code:
NSArray *myLabels = [[NSArray alloc] initWithObjects:
   label1, label2, label3, ... , nil];
Now you can iterate over the labels as you showed.

Best regards,
__________________
Andy, Cambridge Coders Limited, www.cambridgecoders.com
Calcuccino - scientific calculator for the iPhone
CambridgeCoders is offline   Reply With Quote
Reply

Bookmarks

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: 342
13 members and 329 guests
Absentia, cgokey, fiftysixty, givensur, heshiming, iGamesDev, jenniead38, linkmx, mraalex, PixelInteractive, raihan.zbr, Trickphotostudios
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

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