Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let someString:String! = "this is the string";
- let someString:String = "this is the string";
- class MyView : UIView {
- @IBOutlet var button : UIButton!
- var buttonOriginalWidth : CGFloat!
- override func awakeFromNib() {
- self.buttonOriginalWidth = self.button.frame.size.width
- }
- }
- override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell? { return nil }
- var image : UIImage? = UIImage(named: "NonExistentImage")
- if image != nil {
- println("image exists")
- }
- else {
- println("image does not exist")
- }
- class FileSystemItem {
- }
- class Directory : FileSystemItem {
- lazy var contents : [FileSystemItem] = {
- var loadedContents = [FileSystemItem]()
- // load contents and append to loadedContents
- return loadedContents
- }()
- }
- // These classes are buddies that never go anywhere without each other
- class B {
- var name : String
- weak var myBuddyA : A!
- init(name : String) {
- self.name = name
- }
- }
- class A {
- var name : String
- var myBuddyB : B
- init(name : String) {
- self.name = name
- myBuddyB = B(name:"(name)'s buddy B")
- myBuddyB.myBuddyA = self
- }
- }
- var a = A(name:"Big A")
- println(a.myBuddyB.name) // prints "Big A's buddy B"
- class MyViewController: UIViewController {
- var screenSize: CGSize?
- override func viewDidLoad {
- super.viewDidLoad()
- screenSize = view.frame.size
- }
- @IBAction printSize(sender: UIButton) {
- println("Screen size: (screenSize!)")
- }
- }
- if let value = optionalWhichTotallyHasAValue {
- println("(value)")
- } else {
- assert(false)
- }
- println("(value!)")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement