let constant = "Constant cannot be changed"
var variable = "Variable can be changed later"
var x,y: Int
let x = 0, y = 0
This file contains 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
NSInteger x = 30; | |
CGFloat y = (CGFloat)x; |
This file contains 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
let pi: Double = 3.14159 | |
let fpi: Float = 3.14159 | |
let x = Int(pi) // 3 | |
let dpi = Double(pi) | |
let dgf = CGFloat(pi) | |
let array = Array("abc") // array = ["a", "b", "c"] | |
let string = String(["a", "b", "c", "d"]) // string = "abcd" | |
let intConvert = String(44) // let's try String(37.5) |
This file contains 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
// AnyObject might be used in this way | |
// Properties | |
var destinationViewController: AnyObject | |
var toolbarItems: [AnyObject] | |
// Function or Method Arguments | |
func prepareForSegue(segue: UIStoryboardSegue, sender AnyObject) | |
func addConstraints(constraints: [AnyObject]) | |
func appendDigit(sender: AnyObject) |
This file contains 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
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) { | |
if segue.identifier == "ViewImage" { | |
let imageViewController = segue.destinationViewController as ImgurImageViewController | |
let cell = sender as ImageCollectionViewCell | |
if let indexPath = imagesCollectionView.indexPathForCell(cell) { | |
imageViewController.imgurImage = images[indexPath.row] | |
} | |
} | |
} |
This file contains 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
@IBAction func touched(sender: AnyObject) { | |
if let button = sender as? Button { | |
button.setTitle("Touched", forState: .Normal) | |
} | |
} | |
@IBAction func touched(sender: AnyObject) { | |
if sender is UISegmentedControl { | |
let segmentedControl = sender as UISegmentedControl | |
let selectedIndex = segmentedControl.selectedSegmentIndex |
This file contains 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
@IBAction func touched(sender: AnyObject) { | |
if sender is UIButton { | |
let buttonTitle = (sender as UIButton).currentTitle | |
} | |
} |
This file contains 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
for item in toolbarItems! { | |
if let barButtonItem = item as? UIBarButtonItem { | |
// Do something with UIBarButtonItem | |
} | |
if let segmentedControl = item as? UISegmentedControl { | |
// Do something with UISegmentedControl | |
} | |
} |
This file contains 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
// | |
// PlacePickerViewController.swift | |
// TaxiReporter | |
// | |
// Created by Kiattisak Anoochitarom on 2/27/2558 BE. | |
// Copyright (c) 2558 Kiattisak Anoochitarom. All rights reserved. | |
// | |
import UIKit | |
import FacebookSDK |
This file contains 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
package main | |
import "fmt" // another package contains function | |
func main() { | |
var hello = "hello gopher!!" // type inference | |
// can be shorten in -> hello := "hello gopher!!" | |
fmt.Println(hello) | |
arr := [6]int{1, 2, 3, 4, 5} |
OlderNewer