Saturday, June 22, 2019

MOBILE DICE APP COMPLETE CODE 
(XCODE)
SWIFT







import UIKit            //1

class ViewController: UIViewController {              //2
    
    let diceArray = ["dice1", "dice2", "dice3", "dice4", "dice5", "dice6" ]       //3
    
    @IBOutlet weak var diceImageView1: UIImageView!
    @IBOutlet weak var diceImageView2: UIImageView!               //4
    
    var randomDiceIndex1 : Int = 0
    var randomDiceIndex2 : Int = 0                //5
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        updateDiceImages()                              //6
    }

    @IBAction func rollButtonPressed(_ sender: UIButton) {                    //7
        
        updateDiceImages()
        
    }
    

    override func motionEnded(_ motion: UIEvent.EventSubtype, with event: UIEvent?) {
            
        updateDiceImages()                             
   
    }
    
    func updateDiceImages() {                            //8
        
        
        randomDiceIndex1 = Int.random(in: 0 ... 5)                 //9
        randomDiceIndex2 = Int.random(in: 0 ... 5)
        
        diceImageView1.image = UIImage(named: diceArray[randomDiceIndex1])
        diceImageView2.image = UIImage(named: diceArray[randomDiceIndex2])         //10
        
    }
    
    
    
}

*CODEEND


The below shown is the image of The viewcontroller of this following app, simulated in iPhone XS.

 




CODE BREAKDOWN

//1 -> UIKIT being imported from the Xcode library for the essentials in the code.


//2 -> A New class called CLASS VIEWCONTROLER is created which is a super class of UIViewcontroller.
NOTE -  Any code in the format of [ Class superclass : subclass {.....} ] refers to a
super class which has a subclass nested in it.


//3 -> An array is declared using "LET" key word, the array contains all the dice names.


//4 -> IBOutlets being linked to the viecontroller where , the first outlet is linked to the first image (dice1),  the second is linked to the second image (dice2)


//5 -> Two variables is created named randomDIceIndex1 and randomDIceIndex2 which are initially set to a value '0'


//6 -> UpdateDiceImage is a function which is written to update random dice images when roll button is pressed , that function is being called here


//7 -> IBAction function in which triggers after roll button is pressed hence the updateDiceImages function is being called inside


//8 & //9 -> The function updateDiceImages which is used a couple of times is written, where randomDiceIndex1 and randomDiceIndex2 which are set to a default value of '0' are allowed here to come up with any random number between 0-5 using " Int.random(in: 0 ... 5) " key word. The array which is mentioned above which has all the dice are being randomly called here

**there are 6 elements in the array, where as we are calling until 5 here**
this is because the array is counted from '0' ,  which is 0 to 1 to 2 to 3... to 5.


//10 -> "diceImageView1.image = UIImage(named: diceArray[randomDiceIndex1])" This enables the dice images to change randomly with the number in the above line.

------------------------------------------------------------------------------------------

CODE wriiten by - yoshithRoy
project idea    - London App Brewery             





# Terminal Cheatsheet for Mac (Basics)

For other languages other than English------||
                                           _||_
                                           \  /
                                            \/

- [Polska wersja]( https://github.com/0nn0/terminal-mac-cheatsheet/tree/master/polish )
- [Versão em Portuguêse]( https://github.com/0nn0/terminal-mac-cheatsheet/tree/master/portugues )
- [Türkçe Versiyon](https://github.com/0nn0/terminal-mac-cheatsheet/tree/master/turkish)
- [Phiên bản tiếng việt](https://github.com/0nn0/terminal-mac-cheatsheet/tree/master/tieng-viet)
- [Русская версия](https://github.com/0nn0/terminal-mac-cheatsheet/tree/master/russian)
- [中文](https://github.com/0nn0/terminal-mac-cheatsheet/tree/master/中文)
- [Korean](https://github.com/0nn0/terminal-mac-cheatsheet/tree/master/korean)
- [French](https://github.com/0nn0/terminal-mac-cheatsheet/tree/master/french)
- [Shqip (Albanian)](https://github.com/0nn0/terminal-mac-cheatsheet/tree/master/albanian)
- [Spanish (Español)](https://github.com/0nn0/terminal-mac-cheatsheet/tree/master/spanish)


------------

_Letters are shown capitalized for readability only._  _Capslock should be off._
## SHORTCUTS

| Key/Command | Description |
| ----------- | ----------- |
| Ctrl + A   | Go to the beginning of the line you are currently typing on.  This also works for most text input fields system-wide.  Netbeans being one exception |
| Ctrl + E   | Go to the end of the line you are currently typing on.  This also works for most text input fields system-wide.  Netbeans being one exception |
| Ctrl + L   | Clears the Screen |
| Cmd + K    | Clears the Screen |
| Ctrl + U   | Cut everything back to the beginning of line |
| Ctrl + K   | Cut everything forward to end of line |
| Ctrl + W   | Cut one word backwards using white space as delimiter |
| Ctrl + Y   | Paste whatever was cut by the last cut command |
| Ctrl + H   | Same as backspace |
| Ctrl + C   | Kill whatever you are running.  Also clears everything on current line |
| Ctrl + D   | Exit the current shell when no process is running, or send EOF to the running process |
| Ctrl + Z   | Puts whatever you are running into a suspended background process. FG restores it |
| Ctrl + _   | Undo the last command. (Underscore.  So it's actually Ctrl + Shift + minus) |
| Ctrl + T   | Swap the last two characters before the cursor |
| Ctrl + F   | Move cursor one character forward |
| Ctrl + B   | Move cursor one character backward |
| Option + →  | Move cursor one word forward |
| Option + ←  | Move cursor one word backwards |
| Esc + T  | Swap the last two words before the cursor |
| Esc + Backspace | Cut one word backwards using none alphabetic characters as delimiters |
| Tab  | Auto-complete files and folder names |

## CORE COMMANDS

| Key/Command | Description |
| ----------- | ----------- |
| cd [folder] | Change directory e.g. `cd Documents` |
| cd |  Home directory |
| cd ~ |  Home directory |
| cd /  | Root of drive |
| cd -  | Previous directory |
| ls | Short listing |
| ls -l | Long listing |
| ls -a | Listing incl. hidden files |
| ls -lh| Long listing with Human readable file sizes |
| ls -R | Entire content of folder recursively |
| sudo [command] | Run command with the security privileges of the superuser (Super User DO) |
| open [file] | Opens a file ( as if you double-clicked it ) |
| top | Displays active processes. Press q to quit |
| nano [file] | Opens the file using the nano editor |
| vim [file] | Opens the file using the vim editor |
| clear |  Clears the screen |
| reset |  Resets the terminal display |

## CHAINING COMMANDS

| Key/Command | Description |
| ----------- | ----------- |
| [command-a]; [command-b] | Run command A and then B, regardless of success of A |
| [command-a] && [command-b] | Run command B if A succeeded |
| [command-a] \|\| [command-b] | Run command B if A failed |
| [command-a] & | Run command A in background |


## PIPING COMMANDS

| Key/Command | Description |
| ----------- | ----------- |
| [command-a] \| [command-b] | Run command A and then pass the result to command B e.g ps auxwww \| grep google |


## COMMAND HISTORY

| Key/Command | Description |
| ----------- | ----------- |
| history n |  Shows the stuff typed – add a number to limit the last n items |
| Ctrl + r  | Interactively search through previously typed commands |
| ![value] |  Execute the last command typed that starts with ‘value’ |
| ![value]:p |  Print to the console the last command typed that starts with ‘value’ |
| !! |  Execute the last command typed |
| !!:p |  Print to the console the last command typed |

## FILE MANAGEMENT

| Key/Command | Description |
| ----------- | ----------- |
| touch [file] |   Create a new file |
| pwd | Full path to working directory |
| . |  Current folder, e.g. `ls .` |
| .. | Parent/enclosing directory, e.g. `ls ..` |
| ls -l .. | Long listing of parent directory |
| cd ../../ | Move 2 levels up |
| cat | Concatenate to screen |
| rm [file] |  Remove a file, e.g. `rm data.tmp` |
| rm -i [file] | Remove with confirmation |
| rm -r [dir] | Remove a directory and contents |
| rm -f [file] | Force removal without confirmation |
| cp [file] [newfile] | Copy file to file |
| cp [file] [dir] | Copy file to directory |
| mv [file] [new filename] |  Move/Rename, e.g. `mv file1.ad /tmp` |
| pbcopy < [file] | Copies file contents to clipboard |
| pbpaste | Paste clipboard contents |
| pbpaste > [file] | Paste clipboard contents into file, `pbpaste > paste-test.txt` |

## DIRECTORY MANAGEMENT

| Key/Command | Description |
| ----------- | ----------- |
| mkdir [dir] | Create new directory |
| mkdir -p [dir]/[dir] |  Create nested directories |
| rmdir [dir] | Remove directory ( only operates on empty directories ) |
| rm -R [dir] | Remove directory and contents |
| less [file]|  Output file content delivered in screensize chunks |
| [command] > [file] |  Push output to file, keep in mind it will get overwritten |
| [command] >> [file] | Append output to existing file |
| [command] < [file] |  Tell command to read content from a file |

## SEARCH

| Key/Command | Description |
| ----------- | ----------- |
| find [dir] -name [search_pattern] | Search for files, e.g. `find /Users -name "file.txt"` |
| grep [search_pattern] [file] | Search for all lines that contain the pattern, e.g. `grep "Tom" file.txt` |
| grep -r [search_pattern] [dir] | Recursively search in all files in specified directory for all lines that contain the pattern |
| grep -v [search_pattern] [file] | Search for all lines that do NOT contain the pattern |
| grep -i [search_pattern] [file] | Search for all lines that contain the case-insensitive pattern |
| mdfind [search_pattern] | Spotlight search for files (names, content, other metadata), e.g. `mdfind skateboard` |
| mdfind -onlyin [dir] -name [pattern] | Spotlight search for files named like pattern in the given directory |

## HELP

| Key/Command | Description |
| ----------- | ----------- |
| [command] -h |  Offers help |
| [command] --help | Offers help |
| info [command] | Offers help |
| man [command] |  Show the help manual for [command] |
| whatis [command] | Gives a one-line description of [command] |
| apropos [search-pattern] | Searches for command with keywords in description |

-------------------------------------------------infoCredits----------------------------------------------------
-------------------------https://github.com/0nn0/terminal-mac-cheatsheet-----------------------------------------