Skip to content

Instantly share code, notes, and snippets.

View Gabbrolee's full-sized avatar

Gabbrolee

View GitHub Profile
@Gabbrolee
Gabbrolee / gist:7f9dc344f64e0e42072c2c30ec2a2541
Created July 7, 2021 19:00
FOUR PILLARS OF OBJECT ORIENTED PROGRAMMING ( OOP)
Introduction:
Object oriented programming is a programming paradigm base on the concept of object which can contain data and code.
Data: in the form of field (which often refer to as properties or attributes). Code: in the form of procedures (which often refer to as methods) Object: in the form of real world object or things eg cat , human , car , etc.
Code: in the form of procedures (which often refer to as methods)
Object: in the form of real world object or things eg cat , human , car , etc.
one:
Encapsulation: This is an object oriented programming concept that bind together the data and method( functions define inside a class ) that manipulate the data and keeping it private unless declared public.
code snippet:
class Account{
import UIKit
//MARKS:- VARIABLES AND CONSTANTS
/* variables are data stored that can have their value change whenever we want it and constant are value that can not be changed .. advaantage of using var in declaring a variable and let in declaring a constant is that it help xcode to remind us of the constant we have set and whenever we try to change it, it will not xcode will not compile our code and it help to save memory space that is optimization of memory. */
// create a name variable
var name = " James Bond"
// name can be updated without xcode throwing error message and there is no need to redeclare it anymore
name = "Ade Osun"
//MARKS:- TYPES OF DATA
// 1. String : they are combination of characters and it could be of million characters as the case maybe
// string declaration
var country = "Nigeria" //first method is type inference: is when //swift assing a datatype to variable or //constant base on the type of value assign //to the variable
var nation: String //second method is type annotation method
nation = "Nigeria"
//2. Integer: they are positive whole numbers
//MARKS:- OPERATORS: These are the little symbols we learnt in our arithmetics
var a = 10
a = a + 1 /* top up the value of a with 10 and it will make it 11
a = a - 1 reduce the current value of a by 1 and it will make it 10
a = a * a multiply the current value of a by itself and it will make it 100 */
var b = 10
b += 10 // b is now 20
b -= 10 // b is now 10
@Gabbrolee
Gabbrolee / gist:cadd19674642790e91bfce65fca66ece
Created August 3, 2021 18:54
DAY ONE: STRING INTERPOLATION
//MARKS:- STRING INTERPOLATION
// This is a way of combining variable and constant inside a string
var namee = "Tim McGraw"
var age1 = 25
var latitude1 = 36.166667
"Your name is \(namee), your age is \(age), and your latitude is \(latitude)."
// mathematical operation can be perform in string interpolation as well
//MARKS:- ARRAY
// swift use type inference to know what type of data your array holds and it allows you group of data together into collections and allow you access those values in the array using the index.
var evenNumbers = [ 2, 4, 6, 8]
var songs = [ "Shake it off", "You belong with me", "Back to December" ]
// accessing the position of items in the array, you need to use the array name then the position . the first element is at index 0 and so on
songs[0] // Shake it off
songs[1] // You belong with me
@Gabbrolee
Gabbrolee / gist:d6a5cdf69cd36252bde8f1af5767a8fe
Last active August 5, 2021 17:15
DAY ONE : VARIABLE AND STRINGS, DATA TYPES, OPERATION, STRING INTERPOLATION, ARRAY
import UIKit
//MARKS:- VARIABLES AND CONSTANTS
/* variables are data stored that can have their value change whenever we want it and constant are value that can not be changed .. advaantage of using var in declaring a variable and let in declaring a constant is that it help xcode to remind us of the constant we have set and whenever we try to change it, it will not xcode will not compile our code and it help to save memory space that is optimization of memory. */
// create a name variable
var name = " James Bond"
// name can be updated without xcode throwing error message
//there is no need to redeclare it anymore
@Gabbrolee
Gabbrolee / dayTwo.swift
Last active August 8, 2021 09:47
dayTwo
import UIKit
//MARKS:- DICTIONARIES This is can be compare with an array in the sense that, it uses keys to address position of element in a collection but array uses index to access the position of element in a collection
var person = ["first":"Kemi", "second":"Bola", "last":"Temi", "month":"December", "website":"www.google.com"]
person["first"] // output: Kemi
person["month"] // output: December
//MARkS:- from the output above the key is first and the value is Kemi
// dictionaries use keys and values unlike array that use index to search
// for position of items in a collection
@Gabbrolee
Gabbrolee / dayThree.swift
Last active August 8, 2021 09:50
dayThree.swift
import UIKit
// classes, struct, optional, optional chaining, enum
// this function return string but what if the
// haters don't feel like hating today then it
// is optional
// in a layman understanding, it means either one
// has respond to provide to questions or not
// the ? makes it optional
func getHaterStatus(weather:String) -> String? {
if weather == "sunny" {
@Gabbrolee
Gabbrolee / dayFour.swift
Last active August 8, 2021 11:09
dayFour.swift
// struct and classes have their own method and its called properties
// two kind of properties observer and it is willset and didset
//willset provides a new value for the properties
//Didset gives old value
import UIKit
struct Person {
var clothes: String {
willSet {
updateUI(msg: "I'm changing from \(clothes) to \(newValue)")
}