I am starting an app for building a personal wiki. The pages in the wiki can be different types, such as text files, PDF documents, and web pages. I have the following initial model for a page:
class Page {
var title: String = "Page"
var type: UTType
var contents: T
}
The data type T
for contents
should depend on the type of page. For example a plain text page would use a string for contents
, a rich text page would use an attributed string, and a PDF page would use a PDF document.
How do I set the data type for contents
so it can be different types, based on the type of page?