Skip to content

Instantly share code, notes, and snippets.

View iranjith4's full-sized avatar
🏗️
Building Tech for Real estate agents

RanjithKumar Matheswaran iranjith4

🏗️
Building Tech for Real estate agents
View GitHub Profile
@iranjith4
iranjith4 / load-csv-pose-sample.swift
Created May 8, 2023 06:21
Loading a CSV file and reading lines
private func loadPoseSamples() {
var poseSamples: [PoseSample] = []
var text: String
do {
if let path = Bundle.main.path(forResource: Self.POSE_SAMPLES_FILE, ofType: Self.POSE_SAMPLES_FILE_EXT) {
text = try String(contentsOfFile: path, encoding: String.Encoding.utf8)
} else {
print(TAG, "Could not find file.")
return
}
@iranjith4
iranjith4 / readme.md
Last active August 13, 2020 15:05
Great Quotes from Silicon Valley
@iranjith4
iranjith4 / radius-mobile-intern.json
Created December 10, 2019 05:16
Radius Mobile Intern API
{
"message" : "Success",
"success" : true,
"data" : {
"profile" : {
"first_name" : "Christopher",
"middle_name" : "https://randomuser.me/api/portraits/men/78.jpg",
"last_name" : "Shelton",
"profile_image" : "",
"city" : "Krakow",
@iranjith4
iranjith4 / reusableview.swift
Created November 23, 2018 09:29
reusableview
//
// ReusableView.swift
// Ranjithkumar Matheswaran
//
// Created by Ranjithkumar Matheswaran on 31/10/18.
// Copyright © 2018 AgentDesks LLC. All rights reserved.
//
import Foundation
import UIKit
@iranjith4
iranjith4 / reusableview-registering-in-viewcontroller.swift
Last active November 23, 2018 09:28
reusableview-registering-in-viewcontroller
/// Registering for UITableView
myTableView.register(MyCustomTableViewCell.self)
myTableView.register(MyCustomHeaderFooterView.self)
/// Registering for UICollectionView
myCollectionView.register(MyCustomCollectionViewCell.self)
myCollectionView.register(MyCollectionViewReusableView.self)
/// UITableViewCell
class MyCustomTableViewCell: UITableViewCell, ReusableView, NibLoadableView {
}
// Or More suggested way
extension MyCustomTableViewCell: ReusableView, NibLoadableView { }
/// UITableViewHeaderFooterView
class MyCustomHeaderFooterView: UITableViewHeaderFooterView, ReusableView, NibLoadableView {
}
@iranjith4
iranjith4 / reusableview-dequeue-declaration.swift
Created November 23, 2018 09:13
reusableview-dequeue-declaration
//Dequeue methods for UICollectionView
func dequeueReusableCell<T: UICollectionViewCell>(for indexPath: IndexPath) -> T where T: ReusableView {
guard let cell = dequeueReusableCell(withReuseIdentifier: T.defaultReuseIdentifier, for: indexPath) as? T else {
fatalError("Could not dequeue cell with identifier: \(T.defaultReuseIdentifier)")
}
return cell
}
func dequeueReusableSupplementaryView<T: UICollectionReusableView>(ofKind: String, indexPath: IndexPath) -> T where T: ReusableView {
@iranjith4
iranjith4 / reusableview-register-headerfooter-supplementary-declaration.swift
Created November 23, 2018 09:09
reusableview-register-headerfooter-supplementary-declaration
// Registering Supplementary View
func register<T: UICollectionReusableView>(_: T.Type, supplementaryViewOfKind: String) where T: ReusableView {
register(T.self, forSupplementaryViewOfKind: supplementaryViewOfKind, withReuseIdentifier: T.defaultReuseIdentifier)
}
func register<T: UICollectionReusableView>(_: T.Type, supplementaryViewOfKind: String) where T: ReusableView, T: NibLoadableView {
let bundle = Bundle(for: T.self)
let nib = UINib(nibName: T.nibName, bundle: bundle)
register(nib, forSupplementaryViewOfKind: supplementaryViewOfKind, withReuseIdentifier: T.defaultReuseIdentifier)
@iranjith4
iranjith4 / reusableview-register-declaration.swift
Last active November 23, 2018 09:11
reusableview-register-declaration
//CollectionView
extension UICollectionView {
func register<T: UICollectionViewCell>(_: T.Type) where T: ReusableView {
register(T.self, forCellWithReuseIdentifier: T.defaultReuseIdentifier)
}
func register<T: UICollectionViewCell>(_: T.Type) where T: ReusableView, T: NibLoadableView {
let bundle = Bundle(for: T.self)
let nib = UINib(nibName: T.nibName, bundle: bundle)
@iranjith4
iranjith4 / reusableview-identifier-declaration.swift
Created November 23, 2018 09:02
reusableview-identifier-declaration
extension ReusableView where Self: UIView {
static var defaultReuseIdentifier: String {
return String(describing: self)
}
}
extension NibLoadableView where Self: UIView {
static var nibName: String {
return String(describing: self)
}