Skip to content

Instantly share code, notes, and snippets.

View naveedmcs's full-sized avatar
👨‍💻
Nothing is interesting if You are not interested.

Muhammad Naveed naveedmcs

👨‍💻
Nothing is interesting if You are not interested.
View GitHub Profile
@naveedmcs
naveedmcs / ImagePickerClass.swift
Created September 16, 2019 06:57
pick image from gallery or camera
protocol BaseImagePickerVCDelegate: class {
func mySelectedImage(image: UIImage)
}
class BaseImagePickerVC: UIVIewController {
var imagePickerDelegate: BaseImagePickerVCDelegate?
struct alertPicker {
//MARK:- implement socket
extension ChatVC {
func notificationSeenLlist() {
guard let id = notificationId else {
return
}
var seenList = [String]()
@naveedmcs
naveedmcs / SocketManager.swift
Last active September 16, 2019 06:47
helpful for handling socket events , this class is used object as a global instance
import UIKit
import SocketIO
import AVKit
class SocketIOManager: NSObject {
static let sharedInstance = SocketIOManager()
var socket : SocketIOClient!
var manager : SocketManager!
@naveedmcs
naveedmcs / Slider.swift
Created August 29, 2019 13:45
Slider In Swift
extension YourController: UICollectionViewDelegate, UICollectionViewDataSource{
func setSlider(){
let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
layout.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
layout.itemSize = CGSize(width:self.slidercollection.frame.width, height: self.slidercollection.frame.height)
layout.minimumInteritemSpacing = 0
layout.minimumLineSpacing = 0
layout.scrollDirection = .horizontal
@naveedmcs
naveedmcs / UITableView+beginRefreshing.swift
Created August 22, 2019 07:14 — forked from mttcrsp/UITableView+beginRefreshing.swift
Extension that allows programmatic pull to refresh
import UIKit
public extension UITableView {
public func beginRefreshing() {
// Make sure that a refresh control to be shown was actually set on the view
// controller and the it is not already animating. Otherwise there's nothing
// to refresh.
guard let refreshControl = refreshControl, !refreshControl.isRefreshing else {
return
@naveedmcs
naveedmcs / ConstraintUIViewExtension.swift
Created August 21, 2019 13:44
ConstraintUIViewExtension
import UIKit
extension UIView {
func anchor(top: NSLayoutYAxisAnchor?, left: NSLayoutXAxisAnchor?, bottom: NSLayoutYAxisAnchor?, right: NSLayoutXAxisAnchor?, paddingTop: CGFloat, paddingLeft: CGFloat, paddingBottom: CGFloat, paddingRight: CGFloat, width: CGFloat, height: CGFloat) {
translatesAutoresizingMaskIntoConstraints = false
if let top = top {
self.topAnchor.constraint(equalTo: top, constant: paddingTop).isActive = true
// Snippet
typealias AlertActionHandler = ((UIAlertAction) -> Void)
extension UIAlertControllerStyle {
func controller(title: String, message: String, actions: [UIAlertAction]) -> UIAlertController {
let _controller = UIAlertController(
title: title,
message: message,
preferredStyle: self
@naveedmcs
naveedmcs / CustomTextField.swift
Created August 21, 2019 13:17
customTextField
private var maxLengths = [UITextField: Int]()
extension UITextField {
@IBInspectable var placeHolderColor: UIColor?{
get {
return self.placeHolderColor
}
set {
@naveedmcs
naveedmcs / TableViewExtension.swift
Last active August 21, 2019 10:06
tableViewExtension
extension UITableView {
func dequeueCell<T: UITableViewCell>(withIdentifier identifier: String, for indexPath: IndexPath) -> T {
return dequeueReusableCell(withIdentifier: identifier, for: indexPath) as! T
}
}
// usage exampe
let cell: CustomCell = table.dequeueCell(
withIdentifier: identifier,
for: indexPath
@naveedmcs
naveedmcs / toggle section tableView.swift
Last active July 1, 2019 10:22
toggle section tableView
class CategoryVC: BaseVC {
@IBOutlet weak var tbl_cats : UITableView!
var catList : [Category] = []
override func viewDidLoad() {
super.viewDidLoad()
setupView()