-4

In an instructional video I recently watched, entering print() in viewDidLoad() caused the print() text to appear at the end of the text displaying in the console. But when I run the same code, the text appears in the middle of the console (as in, additional text following the body of the print() text displays in the console--see screenshot for example). Here is the code I am referring to:

override fun viewDidLoad() {
    super.viewDidLoad()

    print("Hello World!")

}

screenshot of print() command displaying in the middle of the console instead of the end

jedillon
  • 21
  • 4
  • 3
    There are two side to the Debug area. One side is the Variable view and the other side is the console where print command outputs are viewed. If you look at the bottom right *of the debug area* you will see two blue highlighted boxes. Click the left on off and it will hide the variable area. Then the console will take up the entire debug area. – Asdrubal Jul 30 '16 at 21:36
  • Building on @Asdrubal you can look here: https://developer.apple.com/library/tvos/documentation/DeveloperTools/Conceptual/debugging_with_xcode/chapters/debugging_tools.html – modesitt Jul 30 '16 at 21:45
  • @Asdrubal and @Nucl3ic -- I was not trying to ask about the physical layout of the debug tools, but why the `print()` text "Hello World!" was not the last thing to display in the console. In the instructional video I am following, the `print()` text is the last to display, but not when I tried it myself. I have edited the original question to clarify my meaning. – jedillon Aug 01 '16 at 03:24
  • @BruceDavidWilner -- I've edited the original question to remove my erroneous use of the term "command." – jedillon Aug 01 '16 at 03:27

3 Answers3

1

Bug in Xcode 8: it will print stuff automatically in viewDidLoad, viewDidAppear, etc. You are printing your code in view did load, and Xcode will print logs after view did load, that is why it's in the middle.

Pranav Wadhwa
  • 7,666
  • 6
  • 39
  • 61
0

If you're talking about the console being on the right side: see the two squared icons with a bar inside, highlighted in blue, in the lower right part of Xcode's window? Click on the left one: it will hide the properties panel and expand the console at full width.

If you're talking about the fact that "Hello World!" is in the middle of other text, that's because this other text is debug information that appeared at the same time as your print statement.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
  • 2
    This was stated in a comment. – Michael Jul 30 '16 at 22:36
  • 2
    @Michael Well, if you look at the timestamps in the revisions, I was there first. But does this really matter? – Eric Aya Jul 30 '16 at 22:38
  • 1
    No, you did copy the comment. I saw @Asdrubal's comment roughly 10 minutes before your answer. It is irrelevant. – Michael Jul 30 '16 at 23:11
  • 1
    @Michael I understand now why you think that, but no, I didn't copy. The comment was posted while my answer was deleted - I was editing it to add the second part, after having posted the first part before the comment was there. No that I care that much, but I can call a moderator to prove it if you want. The detailed timeline will show it. And if you want a funny detail: I even posted it as a comment before deleting it and eventually posting it as an answer. It's just a mess, and I understand why one would think what you think, but seriously, no. :) – Eric Aya Jul 30 '16 at 23:16
  • @EricD -- I was not trying to ask about the physical layout of the debug tools (the first part of your answer), but why the `print()` text "Hello World!" was not the last thing to display in the console (the second part of your answer). In the instructional video I watched, the `print()` text is the last to display, but not when I try it myself. I have edited the original question to clarify my meaning. – jedillon Aug 01 '16 at 03:33
0

They are likely using a different Xcode version. Xcode 8 is still in beta and they are printing a lot of different things into the console (especially if you have network requests). The runtime is hitting your print statement before printing some of these other statements.

Jeremy Kates
  • 38
  • 1
  • 4
  • The instructional video was recorded months ago, so it must've been on an early beta. My attempts each used Xcode 8 beta 3, which wasn't released until July 18, 2016. The timing lines up--we must've been using different Xcode beta releases. – jedillon Aug 04 '16 at 19:36