0
votes

I have some platform-agnostic model code that is computing where everything in my app should go. So to layout my NSView objects, all I need to do is to grab the positions from the model code and apply them.

I am aware of the frame property, I can set it, and it works.

But -- is there an expected "way" or "time" to set it? Such as a method to override? Or should I just roll my own the whole way?

Another alternative might be to have constraints that basically say the views should have the coordinates their model tells them to have.

1

1 Answers

0
votes

-[NSView layout] is exactly what you're looking for. It is when views are intended to set the frames of their subviews. So you can subclass NSView, override layout and apply the frames from your model to the subviews of that view.

Translating the to constraints seems unnecessary over just setting the frames.