Protocol typealias declaration with no assignment

ViewModifier protocol is defined as following:

public protocol ViewModifier {
associatedtype Body : View
func body(content: Self.Content) -> Self.Body
typealias Content

how come typealias Content does not have assigment (= Some type), and the compiler does not complain? If I create my own custom protocol is a similar fashion to ViewModifier, the compile complains.

Thanks in advance for your inputs


Probably you are looking an interface description, not the actual source code. Where are you reading it?

in the Xcode 11, when you jump to the definition

Yes. That is just a textual interface summary intended for humans.

Doing “Jump to Definition” for NSView causes this to show up:

open class NSView : NSResponder /* ... */ {
    public init(frame frameRect: NSRect)
    public init?(coder decoder: NSCoder)
    unowned(unsafe) open var window: NSWindow? { get }
    unowned(unsafe) open var superview: NSView? { get }
    // ...

Notice that none of those have concrete implementations and the whole thing would be invalid as real source.

Whenever the full source of the definition is available (such as if it is elsewhere in the project itself), then “Jump to Definition” does lead straight to the real source definition. It falls back to only showing an API summary like that when the source is unavailable (such as if it comes from Apple’s closed‐source system frameworks).

Hmm. is the source code available to look at somewhere?

I don’t think SwiftUI is open source.

thank you. This is helpful

Terms of Service

Privacy Policy

Cookie Policy