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

View Single Post
Old 08-27-2009, 01:25 PM   #9 (permalink)
jonahgabriel
Registered Member
 
Join Date: Feb 2009
Posts: 170
jonahgabriel is on a distinguished road
Default

How about creating an NSMutableDictionary to hold references to the labels:

Code:
NSMutableDictonary *labelDictionary = [[NSMutableDictonary alloc] init];
for (NSInteger i=0; i<50; i++){
    UILabel *lbl=[[UILabel alloc] initWithFrame:CGRect(0,20*i, 100, 20)];
    [lbl setTag:i];
    [lbl setText:[NSString stringWithFormat:@"Label #%d", i]];
    [self.view addSubview:lbl];
    [labelDictonary setObject:lbl forKey:lbl.text];
    [lbl release];
}
Now, whenever you want to get the label, all you have to do is

Code:
UILabel *lbl = (UILabel *)[labelDictionary objectForKey:[NSString stringWithFormat:@"Label #%d", i];
jonahgabriel is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,176
Threads: 93,917
Posts: 402,136
Top Poster: BrianSlick (7,966)
Welcome to our newest member, spiketmr
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:58 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.