Skip to content

Instantly share code, notes, and snippets.

View rajubd49's full-sized avatar

Md Harish Uz Jaman Mridha rajubd49

View GitHub Profile
@rajubd49
rajubd49 / TopViewController.swift
Created July 10, 2018 09:55
Get Top ViewController for iOS using Swift
extension UIApplication {
class func topViewController(base: UIViewController? = UIApplication.sharedApplication().keyWindow?.rootViewController) -> UIViewController? {
if let nav = base as? UINavigationController {
return topViewController(base: nav.visibleViewController)
}
if let tab = base as? UITabBarController {
if let selected = tab.selectedViewController {
return topViewController(base: selected)
}
}
@rajubd49
rajubd49 / HashMap.swift
Last active August 5, 2019 10:47
Swift implementation of Hash Map
import UIKit
var string = "1337"
func convert(string: String) -> Int? {
var total = 0
let valueMap = [
"0" as Character : 0,
"1" : 1,
@rajubd49
rajubd49 / LinkedList.swift
Created August 5, 2019 10:48
Swift implementation of Linked List (Insert, Delete, Special insert).
import UIKit
// Linked List (Insert, Delete, Special insert)
class Node {
let value: Int
var nextNode: Node?
init(value:Int, nextNode: Node?) {
self.value = value
self.nextNode = nextNode
@rajubd49
rajubd49 / code_review.doc
Created June 20, 2022 09:51
Teufel code review
Code review
12: MusicAlbum struct need to confirm Decodable protocol to decode response from url request
25: Initializer need to have albums initialized with default value like init(albums: [MusicAlbum] = [MusicAlbum]())
29: Function name should be in camel case instead of snake case
30: Url needs to be a valid format, otherwise url session will fail to load response
33: Before sink, we need make sure to publish values from main thread using .received(on: DispatchQueue.main)
34: Need to check completion with .finished and .failure case to show appropriate error message if exists.
37: After line 37, we need to store cancellables instance in specified collection
45: showDetailView needs to be a @State property, otherwise we can’t change it’s value inside struct