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
import 'package:flutter/material.dart'; | |
import 'package:intl/intl.dart'; | |
const Color darkBlue = Color.fromARGB(255, 18, 32, 47); | |
void main() { | |
runApp(MyApp()); | |
} |
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
// 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)") | |
} |
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
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" { |
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
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 |
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
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 |
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
//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 |
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
//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 |
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
//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 |
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
//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 |
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
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" |
NewerOlder