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];