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
func exampleFunc(description intArg:Int) { | |
// ... | |
} | |
exampleFunc(description: 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
func exampleFunc(# intArg:Int) { | |
// ... | |
} | |
exampleFunc(intArg: 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
func add(first:Int, second:Int) -> Int { | |
return first+second | |
} | |
add(4, second: 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
func add(first:Int, _ second:Int) -> Int { | |
return first+second | |
} | |
add(4, 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
func defaultParameters(myArg:Int = 0) { | |
// ... | |
} | |
defaultParameters() //passing nothing gives 'myArg' a value of 0 | |
defaultParameters(myArg: 5) //'myArg' will be 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
public class MyClass { | |
private(set) public var myProperty:Int = 0 | |
} | |
//Here’s some code that tests our new property | |
let myObj = MyClass() | |
println(myObj.myProperty) //this line compiles | |
myObj.myProperty = 5 //this causes a compile error |
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
func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]? { | |
var myAction = UITableViewRowAction(style: .Default, title: "My Custom Action", handler: { (action:UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in | |
//block that runs when 'My Custom Action' button is tapped | |
}) | |
//it's useful to differentiate each button with color | |
myAction.backgroundColor = UIColor.lightGrayColor() | |
//create additional actions here |
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 alert = UIAlertController(title: "Title", message: "Message", preferredStyle: .Alert /* or .ActionSheet*/) | |
alert.addAction(UIAlertAction(title: "OK", style: .Default, handler: { (action:UIAlertAction!) in | |
//this block runs when 'OK' is tapped | |
})) | |
alert.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: { (action:UIAlertAction!) in | |
//this block runs when 'Cancel' is tapped | |
})) |
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 alertStyle:UIAlertControllerStyle = UIDevice.currentDevice().userInterfaceIdiom == .Phone ? .ActionSheet : .Alert |
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
table.estimatedRowHeight = 44; | |
table.rowHeight = UITableViewAutomaticDimension |