In this Swift Xcode 6.0.1 example for a table cell, .self is used as a suffix (don't remember seeing self used like that before), and a prefix self. (which of course is everywhere), trying to understand what that really means.
// Register the UITableViewCell class with the tableView
self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: self.cellIdentifier)
Your first usage of self as a prefix is a reference to the instance of the class that contains the method that is currently being invoked. In the second usage, self is referring to a type as a value, in this case UITableViewCell.self refers to the UITableViewCell type
self is a method that returns the receiver of the message. In this case, it returns the Class object for UITableViewCell.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With