Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

newDeveloper

macrumors newbie
Original poster
Jun 13, 2010
12
0
I have created a grouped table view in a program and configured it to 1 section and 4 rows, where I pull in a custom cell that I created (UITableViewCell) using a NIB file, as so...

Code:
if (indexPath.section == 0)
	{
		cell = [tableView dequeueReusableCellWithIdentifier:@"firstlevelcell"];
		if (!cell)
		{
			cell = [[[NSBundle mainBundle] loadNibNamed:@"firstlevelcell" owner:self options:nil] lastObject];
			cell.selectionStyle = UITableViewCellSelectionStyleNone;
		}
...

Now, I want to use that "firstlevelcell" throughout my application in different places, but for this view, I want to use it four times in a row, and change the label to four different values I have stored in an array [0-3].

I feel like if I create an outlet, I have to change the class of the UITableViewCell nib from NSObject to my custom subclass to tie it to that outlet...but that would mean I have to create multiple copies of that NIB if I want to use it elsewhere in the application.

How do I change the value of the labels in that custom NIB when I load it, so that I can use that NIB all over the application???

Does that make sense?
 
So I added...

cell.textLabel.text = @"newDeveloper";

...to the code so that I can set the values...but how do I do that with creating code for each row...since it uses the same nib? Can I just cycle through my array using enumeration for 0 through [array count] and modify the above code to...

cell.textLabel.text = [array objectAtIndex:X];

???
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.