0

Trying to load a few hundred UINib consecutively and really fast (one after the other in less than 0.5sec). UINib contain UIButton and a relatively small sized image (different for each nib).

I have tried this:

UINib *nib = [UINib nibWithNibName:viewName_ bundle:[NSBundle mainBundle]];
        [nib instantiateWithOwner:self options:nil];
        mainView = [[nib instantiateWithOwner:self options:nil] objectAtIndex:0];

and this:

mainView = [[[NSBundle mainBundle] loadNibNamed:viewName_ owner:self options:nil] objectAtIndex:0];

with the last being a few milliseconds faster and CPU usage is 92% vs 97%.

Which is the best way to load these nibs even faster? Or is there a better way to do this?

thanks

George Asda
  • 2,119
  • 2
  • 28
  • 54
  • My first thought is why load a few hundred NIBS at all. Can you elaborate a bit more on what you are trying to achieve. – rckoenes Sep 16 '15 at 09:28
  • @rckoenes it's how the app is set app. Going slowly on the next nib is not a problem. it's when "scrolling" really fast that the CPU gets crazy! (and by scrolling I don't mean scrolling... I mean advancing to the next nib) – George Asda Sep 16 '15 at 10:20
  • Looks to me like the design is fault. To make scrolling fast you will need to reuse as many view a possible. Just like in a table view. The loading will also take time and can't really be improved. But reusing view can. – rckoenes Sep 16 '15 at 10:45
  • @rckoenes thanks for your input. The app has been designed taking all parameters into consideration and this was the best design model. It cannot be changed. Obviously it would take more than a comment to explain why we went that way. you have to trust me on that – George Asda Sep 16 '15 at 11:05
  • I think the problem is the UIButtons that I am loading. When the buttons are less than 10 it's not a problem. however when the are more than 25 then all hell breaks loose. – George Asda Sep 16 '15 at 15:32

1 Answers1

0

Ok the solution was really easy to this. In case someone else comes across. Wait for Apple to fix it!

9.1 works like a charm. Everything loads super fast as expected. Thanks for your input.

George Asda
  • 2,119
  • 2
  • 28
  • 54