Skip to content

Instantly share code, notes, and snippets.

View imnaveensharma's full-sized avatar

Naveen Sharma imnaveensharma

  • TechAhead Software Pvt. Ltd.
  • Noida, India
View GitHub Profile
@imnaveensharma
imnaveensharma / DebugLog.swift
Created July 13, 2020 14:47
Constant file with custom methods to print logs with extra informations for development/debug phase only.
#if DEBUG
func dLog(message: String, filename: String = #file, function: String = #function, line: Int = #line) {
print("[\((filename as NSString).lastPathComponent):\(line)] \(function) - \(String(describing: message))")
}
func classStart(filename: String = #file, function: String = #function, line: Int = #line) {
print("ClassStart", "[\((filename as NSString).lastPathComponent):\(line)] \(function)")
}
func classEnd(filename: String = #file, function: String = #function, line: Int = #line) {
@imnaveensharma
imnaveensharma / UIWebView_References_Finder.rtf
Last active July 16, 2020 11:17
Find UIWebView references in iOS App
To detect use of UIWebView in project.
1. Open Terminal
2. CD <Path to your App>
3. Press return
4. grep -r UIWebView .
To detect use of UIWebView in binary frameworks.
@imnaveensharma
imnaveensharma / UIKit_AddTarget.swift
Last active July 25, 2020 04:51
Add target through selector
self.btn.addTarget(self, action: #selector(tapBtn(sender:)), for: .touchUpInside)
// MARK: - Selectors Actions ::
@IBAction func tapBtn(sender: UIButton) {
}
class func emptyTableCell() -> UITableViewCell {
let cellDefault: UITableViewCell = UITableViewCell(style: .default, reuseIdentifier: "Cell")
cellDefault.selectionStyle = .none
cellDefault.textLabel?.text = ""
cellDefault.imageView?.image = nil
return cellDefault
}
@imnaveensharma
imnaveensharma / UIKit_ScrollableTableHeaderView.swift
Created July 24, 2020 04:31
Scroll the header view along with the UITableView
extension ViewController: UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
guard let tableView = scrollView as? UITableView,
let visible = tableView.indexPathsForVisibleRows,
let first = visible.first else {
return
}
let headerHeight = tableView.rectForHeader(inSection: first.section).size.height
@imnaveensharma
imnaveensharma / UIKit_ClickableLabel.swift
Last active July 24, 2020 05:09
Enable user interaction on UILabel by UITapGestureRecognizer
private func makeLabelClickable() {
self.label.isUserInteractionEnabled = true
let guestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(labelClicked(_:)))
self.label.addGestureRecognizer(guestureRecognizer)
}
@objc func labelClicked(_ sender: Any) {
}
import UIKit
import AWSS3
//pod 'AWSS3'
//https://github.com/maximbilan/Swift-Amazon-S3-Uploading-Tutorial
//https://www.swiftdevcenter.com/upload-image-video-audio-and-any-type-of-files-to-aws-s3-bucket-swift/
typealias progressBlock = (_ progress: Double) -> Void
typealias completionBlock = (_ response: Any?, _ error: Error?) -> Void
@imnaveensharma
imnaveensharma / UIKit_UIRefreshControl.swift
Created July 27, 2020 10:04
Add "Pull to Refresh" and "Load More" on UITableView and UICollectionView
//Step 2: Install below given Pod
pod 'CCBottomRefreshControl'
//Step 2: Add below given line in bridging header file
#import <CCBottomRefreshControl/UIScrollView+BottomRefreshControl.h>
//Step 3:
@IBOutlet private weak var tblView: UITableView!
private func registerNibs() {
self.tblView.register(UINib(nibName: "TableHeaderView", bundle: nil), forHeaderFooterViewReuseIdentifier: "TableHeaderView")
self.tblView.register(UINib(nibName: "TableFooterView", bundle: nil), forHeaderFooterViewReuseIdentifier: "TableFooterView")
self.tblView.register(UINib(nibName: "TableViewCell", bundle: nil), forCellReuseIdentifier: "TableViewCell")
}
// MARK: - Extension :: UITableViewDelegate, UITableViewDataSource ::
extension ViewController: UITableViewDelegate, UITableViewDataSource {
@IBOutlet private weak var collectionView: UICollectionView!
private func registerNibs() {
self.collectionView.register(UINib(nibName: "CollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "CollectionViewCell")
}
// MARK: - Extension :: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout ::
extension MyProfileViewC: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {