-3

image 1.0 I'm curious,how it can ..., and why?

image 1.1

if i use { get } to declare properties in a class, it will report an error.

AnderCover
  • 2,488
  • 3
  • 23
  • 42
dyouknow
  • 1
  • 4
  • 1
    As they used to say back in the day, RTFM: https://docs.swift.org/swift-book/LanguageGuide/Protocols.html#ID269 and https://docs.swift.org/swift-book/LanguageGuide/Properties.html – lazarevzubov Dec 08 '22 at 06:44
  • Hello, you instead of using links to screenshots it's better to copy/paste code snippet. Or you could add your screenshots directly in the question. – AnderCover Dec 08 '22 at 10:17
  • Please provide enough code so others can better understand or reproduce the problem. – Community Dec 08 '22 at 22:23

1 Answers1

0

You are not seeing Foundation.ProcessInfo implementation only a generated interface. That is why you have things like :

open var hostName: String { get }

The implementation is elsewhere and you don't have any details about it, you only have informations you need to use ProcessInfo in your code. For instance you have no internal or private members declared in the generated interface.

XXProcessInfo on the other hand is a class that you are creating and you need to provide the implementation for you properties.

AnderCover
  • 2,488
  • 3
  • 23
  • 42