dotnet / dotnet/macios

Expose [NS|UI]View.Subviews with NSArray variant

Open
#5,325 10 comments 0 reactions 0 assignees View on GitHub
breaking-changes enhancement iOS macOS
Dominant language
C#
Stars
2.9k
Forks
576
Avg merge
2d 13h
Merged PRs (30d)
96

Description

### Steps to Reproduce

1. Query NSView.Subviews
2. Observe that every time we call it, we marshal an array

### Expected Behavior
We should have an API endpoint that exposes an NSArray.

### Actual Behavior
There is none.

### Notes

Scenario:
```
NSView view = ...;
for (int i = 0; i < view.Subviews.Length; ++i) {
var subView = view.Subviews [i];
...
}
```

The above code would marshal the array twice, every time we iterate. Also, array length queries would have to marshal the array to managed, so simply doing:
```
bool hasChildren = view.Subviews.Count > 0;
```

Having an NSArray based overload would avoid that and help for performance with multiple subviews in the NSView.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.