I having some Performance troubles with my app:
It takes more than 2 seconds to load -> So straight away I went to Apple documentation
In the section named "Avoid the Overuse of Views" at the bottom I got very confused:
I indeed adding a lot of NSViews
(Guess I overusing them).
"
Instead, you should consider writing your own custom classes that can be managed by a higher-level NSView
subclass. The drawing code of your NSView
subclass can then be optimized to handle your custom objects.
"
My Question is:
How can I write my own custom classes that can be managed by a higher -level NSView
subclass -> any example ?
Only thing I thought was a CALayer
.
Is adding CALayer
subclasses are better than adding NSView
?
Would it increase my poor performance a bit ?
Or there is something new to learn ?
EDIT:
Currently I have NSView
s where I adding 15 NSView
as a subview to them and I can add 15CALayer
s instead :-/
Have you profiled your App? Before ripping your view hierarchy apart, use instruments with the time profiler to find out where the time is actually being spent.
CALayers are more efficient than UIViews, and it is recommended to avoid using drawRect if you don't need to, but before resorting to a rewrite, you need to know where your App is actually spending its time.