Skip to content

Instantly share code, notes, and snippets.

@StuartGrossman
Created June 16, 2014 16:19
Show Gist options
  • Save StuartGrossman/6b75db0d194aaec250db to your computer and use it in GitHub Desktop.
Save StuartGrossman/6b75db0d194aaec250db to your computer and use it in GitHub Desktop.
Swift Notes
Swift- Programming Language
Swift is apples new rendition of a modern programming Language. It is an object orientated Language and element’s from JavaScript, C++, ruby, and many others.
Using swift and xcode gives you access to auto complete methods, and a huge array of development tools at your fingertips.
This will be a short introduction to they syntax of the Language.
- Declaring a variable
Any variable described outside the 'general' function is a golbal variable.
must always like Javascript place 'var' infront of variable name
-Delcaring Structures
struct 'hashname'{
var name = "un-Named"
var desc = "description"
}
- Delcaring Functions
func 'Function Name'(argument : argument-type) -> 'output'/optional {
- logic
}
example :
func textFieldShouldReturn(textField: UITextField!) -> Bool{
textField.resignFirstResponder();
return true
}
- Declaing an array/ adding to an array
first declare a variable -
var array = [] or var array = []()' using the closed parenthases gives a closed description to an object if its native state was not that of an array'
a simple function to add elements to our new array variable
struct list{
var name = "un-Named"
var desc = "description"
}
var lists = list[]() // Sets lists to empty array
func AddElementsToArray(name: String, desc: String){ // passes fuc two arguemnts both strings
var list.append()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment