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

MvR

macrumors newbie
Original poster
Jul 29, 2008
12
0
I have a .xib file containing a single custom UITableViewCell at the top level, as well as the File's Owner (NSObject) and First Responder.

From the many examples posted online, I then do

Code:
NSArray *topObjs = nil;
topObjs = [[NSBundle mainBundle] loadNibNamed:@"MyTableCell" owner:self options:nil];
MyTableCell *cell = (MyTableCell *)[topObjs [B]objectAtIndex:1[/B]];
This all works fine in the simulator. The array topObjs contains two objects.

When running on the device however, the array only contains a single object, forcing the following change:

Code:
MyTableCell *cell = (MyTableCell *)[[B]topObjs objectAtIndex:0[/B]];

Could anyone please explain this difference? Thanks.
 

SqueegyX

macrumors regular
Mar 24, 2008
108
1
Whats the object in the forst spot in the simulator?

And you should probably set the class of the File's Owner to the class that wil be using that xib file (MyTableCell).
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
I'm not sure of what the objects are in the array but I don't think that's how you should do this. Instead, have an outlet for the tableviewcell in your view controller. Set the File's Owner type correctly and connect the cell to the outlet in the File's Owner. Once you load the nib the outlet will hold the pointer to your tableview cell.

Many examples posted online? I didn't think anyone was doing it this way.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.