Is it better to put several views in one nib file instead?
Thank开发者_C百科s, Reshef
Some time ago I performed test like this:
cellForRowAtIndexPath_method:
....
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle]
loadNibNamed:@"MyCell"
owner:nil options:nil];
for ( id currObject in topLevelObjects ) {
if ( [currObject isKindOfClass:[MyCell class]]
&& [[currObject reuseIdentifier] isEqualToString:MyCellIdentifier] ) {
cell = (MyCell *) currObject;
}
}
}
.....
I had several cells in one file - MyCells.xib. And I got a HUGE (like from 1.5 - 2 seconds for loading "5-cells-in-one-file" file to 0.1 seconds to load a file with one cell per file on iPhone 2G) performance boost, when I split this file to a separate cells like MyCell1.xib, MyCell2.xib etc.
It could surprise you, but the lack of a performance was on a loadNibNamed invocation, not a "for" cycle.
So, I'd suggest to use separate files if you are going to load these views oftenly.
精彩评论