Skip to content

Instantly share code, notes, and snippets.

@MoussaHellal
MoussaHellal / valueTypes.swift
Created April 26, 2023 15:43
value types in swift
struct Book {
var title: String
init(title: String) {
self.title = title
}
}
var bookOne = Book(title: "A Game of Thrones (1996)")
var bookTwo = bookOne // bookTwo now created a new copy from bookOne
@MoussaHellal
MoussaHellal / ClassReferenceType.swift
Last active April 26, 2023 15:46
reference type in Swift
class Book {
var title: String
init(title: String) {
self.title = title
}
}
var bookOne = Book(title: "A Game of Thrones (1996)")
var bookTwo = bookOne // bookTwo now refers to the same instance as bookOne
@MoussaHellal
MoussaHellal / OptionalChaining.swift
Last active April 24, 2023 15:58
Optional Chaining example in Swift
struct Person {
var name: String
var information: Information?
}
struct Information {
var id: String
var age: Int
}
@MoussaHellal
MoussaHellal / suspended.swift
Created April 22, 2023 08:22
These methods are used in suspended state
func applicationDidReceiveMemoryWarning(_ application: UIApplication) {
// It is called when the app receives a memory warning
// This method can be used to release any resources that can be recreated when the app is launched again
}
func applicationWillTerminate(_ application: UIApplication) {
// It is called when the app is about to terminate
// This method can be used to save data or perform other cleanup tasks before the app is terminated
}
@MoussaHellal
MoussaHellal / WillEnterForeground.swift
Created April 22, 2023 08:19
Used when app return back to foreground state
func applicationWillEnterForeground(_ application: UIApplication) {
// It is called when the app is about to enter foreground
// For example, when the user moves back to the app from another app or from the home screen
// You can use this to prepare your application for resuming from the background state
}
@MoussaHellal
MoussaHellal / DidEnterBackground.swift
Created April 22, 2023 08:14
Used when app enters Background
func applicationDidEnterBackground(_ application: UIApplication) {
// It is called when the app switched the background state
// For example, when the user move to another app
// You can use this method to cleanup tasks, save data or stop timers
}
@MoussaHellal
MoussaHellal / DidBecomeActive.swift
Created April 22, 2023 08:10
used when app becomes active
func applicationDidBecomeActive(_ application: UIApplication) {
// It is called when the app has become active (in the foreground)
// For example, when a user taps on the app in home screen to launch it
}
@MoussaHellal
MoussaHellal / WillResignActive.swift
Created April 22, 2023 08:06
used when text message or a phone call is received
func applicationWillResignActive(_ application: UIApplication) {
// It is called in the App Delegate when the app is about to move from active to inactive state
// For example, text message or a phone call is received
}
struct AppConstants {
// static let baseURL = "https://dev.newserver.com"
static let baseURL = "https://newserver.com"
}
import Foundation
struct AppConstants {
static let baseURL = "https://dev.newserver.com"
// static let baseURL = "https://newserver.com"
}