Good day friends!
I have very strange performance results on loading Nib files. Here is a screen from TimeProfiler:
Overall it sometimes takes more than 1200 ms to load a simple viewController that has 2 nibs. Nibs are very simple. Here is an example. As you can see from screenshot above, it takes 311 ms to be loaded:
The code I use to load nibs:
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setupXib()
}
func setupXib() {
NSBundle.mainBundle().loadNibNamed("TimeSaver", owner: self, options: nil)
bounds = view.bounds
addSubview(view)
setup()
}
func setup() {
slider.maximumValue = 30.0
slider.minimumValue = 1.0
slider.value = 5.0
timeLabel.text = "\(sliderValue.format(format)) min"
}
I don't know if it might cause a problem, but this app uses App Groups (for WatchExtension). As you see I call nibs from mainBundle as they all are in main target. May it be the reason?
Thank you!
So the problem was not in nib files at all. It was about custom font that was not installed properly. It was in list in Storyboard, but it was not a member of correct target. So the app was looking through everywhere to find a damn font - and that was the performance issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With