Re: Subviews Order in XCode/IB

Fritz Anderson
 

To repeat the old, old counter-question…

What are you trying to accomplish? Why do you care?

Musings follow on why it might be futile to rely completely on array index.

---

The documentation for `-[NSView subviews]` says the order is usually Z order, or order of insertion, whether in the XIB or programmatically. Maybe insertion is the tiebreaker for Z.

For my part, I'd never keep creation order (if that's what order-in-XIB means) straight in my head. Rather than rely on index as a stable identified of a subview, it'd be easier to leave the ordering of `subviews` be and rely on the `tag` property of each subview for indexing.

    — F


On Jan 20, 2020, at 7:32 AM, Dave <dave@...> wrote:

Hi All,

I have a number of subviews in a view, in IB it looks like this:

NSView1
NSView2
NSButton1
NSButton2

However when I look in the Views subviews property in shows:

NSView1
NSButton1
NSButton2
NSView2

I thought that the order in IB was the order would same as the subviews array and it seems to be most of the time.

Is this not the case?

All the Best
Dave




Join xcode@apple-dev.groups.io to automatically receive all group messages.