Something strange on this forum.
The abstract of your question is:
private func setupCollectionView() { let registration = UICollectionView.CellRegistrationUICollectionViewListCell, Article { cell, _, item in var content = cell.defaultContentConfiguration() content.text = "title"
And the first line
Code Block | private func setupCollectionView() { |
doesn't show in the post itself !
Now back to your question.
I tested your code (which is exactly what is proposed in documentation), and initially I got content type as UIContentConfiguration (which is a protocol) not UIListContentConfiguration (which is a struct with text property).
Could you check the type of content ? Error message seems to show it is UIContentConfiguration
So you could also test
Code Block | let registration = UICollectionView.CellRegistration<UICollectionViewListCell, Article> { cell, _, item in |
| if var content = cell.defaultContentConfiguration() as? UIListContentConfiguration { |
| content.text = "title" |
| cell.contentConfiguration = content |
| } |
| } |
Note: I tested the following
Code Block | let registration = UICollectionView.CellRegistration<UICollectionViewListCell, Int> { cell, _, item in |
| var content = cell.defaultContentConfiguration() as? UIContentConfiguration |
| content.text = "title" |
| cell.contentConfiguration = content |
| } |
and got the exact same error message as yours :
Value of type 'UIContentConfiguration?' has no member 'text'.
That seems to confirm the problem.