Created
June 18, 2015 03:57
-
-
Save cdl/60f640ea2aa8f4b0d952 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// view contains a label and a button - curious about lines 11 through 14 | |
class ViewController: UIViewController { | |
@IBOutlet weak var label: UILabel! | |
// ... | |
@IBAction func didPressButton(sender: AnyObject) { | |
let date = NSDate() | |
// what's the difference between doing: | |
label.text = "Button pressed at \(date)" | |
// versus doing: | |
self.label.text = "Button pressed at \(date)" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In Objective-C, self would be required to specify that it is a function of the View Controller. In Swift, it isn't necessary to start with self (They do the same thing, but the version without self is preferred).