Documentation for UIListContentConfiguration is incomplete in UIKit

The documentation for UIListContentConfiguration states that I can get the default content configuration of a UICollectionViewCell by getting the cells default content configuration. In practice, however, this presents an error in the compiler:

let choiceRegistration = UICollectionView.CellRegistration<UICollectionViewCell, SurveyItem> { cell, indexPath, item in
            cell.configurationUpdateHandler = { cell, state in
                switch item.type {
                    case .choice(let letter, let text):
                        cell.defaultContentConfiguration()
...
}

The error shown when calling cell.defaultContentConfiguration() is Value of type 'UICollectionViewCell' has no member 'defaultContentConfiguration'. Instead, I need to initialise a content configuration using UIListContentConfiguration.cell() to get the default content configuration.

This needs to be reflected in the documentation in UIKit.

Answered by darkpaw in 848888022

The thing to do here is to raise this as a bug so that Apple can update the documentation. You can do so at: https://feedbackassistant.apple.com/

Just mentioning it in a post on the Developer Forums is unlikely to get that change actioned, because we're just random developers like you.

Accepted Answer

The thing to do here is to raise this as a bug so that Apple can update the documentation. You can do so at: https://feedbackassistant.apple.com/

Just mentioning it in a post on the Developer Forums is unlikely to get that change actioned, because we're just random developers like you.

Done: FB18833847 (Documentation for UIListContentConfiguration is incomplete in UIKit). Thank you @darkpaw

I don't think there's anything wrong with the documentation.

states that I can get the default content configuration of a UICollectionViewCell

The documentation doesn't actually state this. UICollectionViewCell is just a generic cell type where you, as a developer, can customise its contents and layout. So while it does have a defaultBackgroundConfiguration() method, there is no specific default content configuration that can exist.


What the documentation does say is this:

For views like cells, headers, and footers, use their defaultContentConfiguration() to get a list content configuration that has preconfigured default styling. Alternatively, you can create a list content configuration from one of the system default styles.

If you navigate to the defaultContentConfiguration() method, you will see that it is defined on UICollectionViewListCell. This is the type you use for creating standard cells in a list with list-specific features. If you aren't using this type of cell or want different default styling, then you can follow the alternative and use one of the static UIListContentConfiguration methods.


So maybe the documentation can be clearer in specifying UICollectionViewListCell, but I think its inferred with all of the list types, detailed further in sample projects and other documentation pages, and also the fact that you are creating a list.

UICollectionViewCell however does have a contentConfiguration property which I can set to be the default content configuration I create. So I think that this is an issue with the documentation that needs to be addressed.

Documentation for UIListContentConfiguration is incomplete in UIKit
 
 
Q