Skip to content

Instantly share code, notes, and snippets.

View igorleonovich's full-sized avatar
🥊
Stay hungry, stay foolish.

Igor Leonovich igorleonovich

🥊
Stay hungry, stay foolish.
View GitHub Profile
extension String {
static func pointer(_ object: AnyObject?) -> String {
guard let object = object else { return "nil" }
let opaque: UnsafeMutableRawPointer = Unmanaged.passUnretained(object).toOpaque()
return String(describing: opaque)
}
}
@igorleonovich
igorleonovich / Array+Sliced.swift
Last active August 10, 2023 21:35
Slicing arrays by specified slice size
import Foundation
extension Array where Element: Any {
func sliced(sliceSize: Int) -> [[Element]] {
var result = [[Element]]()
guard count > 0 else { return result }
let slicesCount = Int(ceil(Double(count) / Double(sliceSize)))
@igorleonovich
igorleonovich / UIView+Blur.swift
Last active June 24, 2024 10:10
Blur effect with given intensity
import UIKit
import SnapKit
extension UIView {
// MARK: Blur
func addBlur() {
backgroundColor = .clear
let blurView = makeBlurView()
@igorleonovich
igorleonovich / UITableView+IndexPathForCellNumber.swift
Last active August 6, 2023 11:10
Returns indexPath of given ordered cell number for any section/rows configuration
import UIKit
extension UITableView {
func indexPath(for cellNumber: Int) -> IndexPath {
// Returns indexPath of given ordered cell number for any section/rows configuration
var cellIndex = 0
var sectionIndex = 0
var rowIndex = 0
while sectionIndex < numberOfSections, cellIndex < cellNumber - 1 {