0

I can see the Assistant Editor, but using println() doesn't print anything to the console, even println("hello world") doesn't print anything!

here is a sample code (am not concerned with memory leaks)

class Person {
    let name: String
    init(name: String) {
        self.name = name
        println("\(name) is being initialized")
    }
    deinit {
        println("\(name) is being deinitialized")
    }
}

var reference1: Person?
var reference2: Person?
var reference3: Person?

reference1 = Person(name: "John Appleseed")
reference2 = reference1
reference3 = reference1

reference1 = nil
reference2 = nil
reference3 = nil

here is a snapshot

enter image description here

is it just an Xcode 6 beta 2 problem ?

ielyamani
  • 17,807
  • 10
  • 55
  • 90
  • possible duplicate of [Memory leaks in the swift playground / deinit{} not called consistently](http://stackoverflow.com/questions/24021340/memory-leaks-in-the-swift-playground-deinit-not-called-consistently) – Grimxn Jul 03 '14 at 11:14
  • NO no no, am not concerned with memory leaks, this was just a fancy sample code, `println()` doesn't work for me on xcode 6 beta 2! – ielyamani Jul 03 '14 at 11:19
  • 1
    You're right, it doesn't work for me either. Works fine in REPL though. You should raise a bug with Apple. – Ashley Mills Jul 03 '14 at 11:21
  • that's what I was thinking @AshleyMills thanks – ielyamani Jul 03 '14 at 11:22
  • 1
    Try to click on the "Console Output" rectangle, for me the console is initially collapsed. – Pierre Jul 03 '14 at 12:43

2 Answers2

0

When I try that in playground (exact copy & paste) I do see the println from the init being printed. You won't see the deinit because it won't actually be called in the playground.

See this question/answer.

Community
  • 1
  • 1
Grimxn
  • 22,115
  • 10
  • 72
  • 85
  • the deinitializer would be called after `reference3 = nil`, this just a sample code, even `println"hello world!"` doesn't work for me, what is the problem? – ielyamani Jul 03 '14 at 11:16
0

This happens because Xcode 6 is in beta. Various things within the playground fail intermittently, there is nothing wrong with your code.

ColinE
  • 68,894
  • 15
  • 164
  • 232