No member "orientation" on UIDevice.rx

Hi… I’m following this fantastic book written on an excellent topic! I tried typing in the following example in an ordinary ViewController class in my project with Rx. These lines come from page 34.

UIDevice.rx.orientation
  .subscribe(onNext: { current in
    switch current {
      case .landscape:
        ... re-arrange UI for landscape
      case .portrait:
        ... re-arrange UI for portrait
    }
})

Error is: Type Reactive has no member orientation.

A question or two:

  1. If the book is outdated, how do I go about finding what the real code should be?
  2. How should this code be written today?

Thank you ver much and I look forward to progressing through the book – hopefully with more compilable examples!

Oops… just read the NEXT line that says it’s a “fictional” property… ahah!

2 Likes

yes I don’t think there is a built-in property like this, but after reading through the first few chapters + the 2 chapters on RxCocoa you should be able to very easily create one for yourself :slight_smile: