Reputation: 61
I am new to swift and iOS development and wanted to build a simple Hello World
app but I don't know where to write the println
or find any tutorials as all are using the UIStoryboard
. Could you tell me how to output hello world
without using UIStoryboard
and which file to write it. Thanks a lot.
Upvotes: 0
Views: 887
Reputation:
To print the message in the Xcode console (you can do this in any file):
println("Hello World!)
If you want to see the message in the simulator (put this in your view controller file):
override func viewDidLoad() {
super.viewDidLoad()
var helloWorldLabel = UILabel(frame: CGRectMake(0, 0, 200, 21))
helloWorldLabel.text = "Hello World!"
self.view.addSubview(helloWorldLabel)
}
As a beginner program, I found the WWDC videos very helpful, you might want to check them out.
Hope this helps, Will
Upvotes: 3
Reputation: 11
In objective c we use the NSLog and in swift we use the println , to check the output in console . suppose in a method we want to check the conditional statement like if -else :
if error != nil {
println("Error: \(error)") //
}
else {
println("Successfully")
println("we can also use the break points to check the value")
}
Upvotes: -1