Skip to content

Instantly share code, notes, and snippets.

View iranjith4's full-sized avatar
:octocat:
Building Tech platform for real estate team and indie agents.

RanjithKumar Matheswaran iranjith4

:octocat:
Building Tech platform for real estate team and indie agents.
View GitHub Profile
/// 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)
}
@iranjith4
iranjith4 / reusableview-protocol-declaration.swift
Last active November 23, 2018 09:03
reusableview-protocol-declaration
protocol ReusableView: class {
static var defaultReuseIdentifier: String { get }
}
protocol NibLoadableView: class {
static var nibName: String { get }
}
@iranjith4
iranjith4 / uitableviewcell-register-old-methods.swift
Last active November 23, 2018 06:28
uitableviewcell-register-old-methods.swift
///UITableView
myTableView.register(MyCustomTableViewCell.self, forCellReuseIdentifier: "MyCustomTableViewCell")
//HeaderFooterView
myTableView.register(UINib(nibName: String(describing: MyCustomTableViewHeaderFooterView.self), bundle: nil), forHeaderFooterViewReuseIdentifier: String(describing: MyCustomTableViewHeaderFooterView.self))
//And you have used it like :
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let header :MyCustomTableViewHeaderFooterView = tableView.dequeueReusableHeaderFooterView(withIdentifier: String(describing: MyCustomTableViewHeaderFooterView.self)) as! MyCustomTableViewHeaderFooterView
return header
@iranjith4
iranjith4 / ios-10-all-font-names.swift
Created November 27, 2017 14:46 — forked from tadija/FontNames-iOS-17.4.swift
iOS 10 - All Font Names
UIFont.familyNames.sorted().forEach{ familyName in
print("*** \(familyName) ***")
UIFont.fontNames(forFamilyName: familyName).forEach { fontName in
print("\(fontName)")
}
print("---------------------")
}
/*
*** Academy Engraved LET ***

Doc Template for Library Plugins

Overview

These template files will help you write documentation for library plugins.

If you wish to create a library plugin, you can code it in 2 ways:

  • Lua code. It's much easier to create a plugin that works cross-platform, but you are limited to what's available in the Lua API's. To create a new project, use the Project Template for Library Plugins (Lua).
  • Native code. You have to generate binaries for each platform, but you have complete access to the native API's of the underlying platform. To create a new project, use the 'App' template that's available in the CoronaEnterprise install.

Keybase proof

I hereby claim:

  • I am iranjith4 on github.
  • I am iranjith4 (https://keybase.io/iranjith4) on keybase.
  • I have a public key whose fingerprint is E5D7 9679 7498 084C 2F73 366F 976C 15E1 E68B FEF6

To claim this, I am signing this object: