Skip to content

Incorrect nullability on IUITableViewDataSource and IUITableViewDelegate #21957

@marcoburato-ecutek

Description

@marcoburato-ecutek

Apple platform

iOS

Framework version

net8.0-*

Affected platform version

.NET 8.0.404, iOS workload 18.0.8319/8.0.100

Description

Some methods have nullability that does not match the actual APIs.

For instance:

IUITableViewDataSource

public string? TitleForHeader(UITableView tableView, nint section)
public string? TitleForFooter(UITableView tableView, nint section)

produce a compilation warning because the method in the interface is declared with a non-nullable return type.
However, the native APIs do allow a null return:

optional func tableView(
    _ tableView: UITableView,
    titleForHeaderInSection section: Int
) -> String?
optional func tableView(
    _ tableView: UITableView,
    titleForFooterInSection section: Int
) -> String?

IUITableViewDelegate

public NSIndexPath? WillSelectRow(UITableView tableView, NSIndexPath indexPath)

produces the same warning for the return value, even though in the native API it's nullable:

optional func tableView(
    _ tableView: UITableView,
    willSelectRowAt indexPath: IndexPath
) -> IndexPath?

These are just the methods that popped warnings in my code, but it looks like there are a few more to fix in these interfaces.

Steps to Reproduce

None (see source code)

Did you find any workaround?

No response

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions