Skip to content

Instantly share code, notes, and snippets.

View dilipiOSDeveloper's full-sized avatar
🏠
Working from home

Dilip Tiwari dilipiOSDeveloper

🏠
Working from home
View GitHub Profile
write this code in method.
let message = messages[indexPath.row]
if indexPath.row == 0 {
return NSAttributedString(string: message.date.dateString(), attributes: [NSAttributedStringKey.font : UIFont.systemFont(ofSize: 13.0, weight: .bold)])
}else {
let previousMessage = messages[indexPath.row - 1]
if Calendar.current.isDate(previousMessage.date, inSameDayAs: message.date) {
return nil
import UIKit
import SystemConfiguration
import Foundation
import JSQMessagesViewController
import SDWebImage
import MobileCoreServices
import Alamofire
class ChatViewController: JSQMessagesViewController,UIImagePickerControllerDelegate,UINavigationControllerDelegate {
// MonthYearPicker.swift
import UIKit
class MonthYearPickerView: UIPickerView, UIPickerViewDelegate, UIPickerViewDataSource {
var months: [String]!
var years: [Int]!
///
func printItem(_ data: Data, withFilePath filePath: String){
printController = UIPrintInteractionController.shared
printController?.delegate = self
let printInfo = UIPrintInfo.printInfo()
printInfo.outputType = .general
printInfo.jobName = "QR Code Image"
printInfo.duplex = .longEdge
printController?.printInfo = printInfo
@dilipiOSDeveloper
dilipiOSDeveloper / Extension.swift
Last active August 31, 2018 05:54
Important Extension Used in Swift for adding more functionality in iOS App.
// Extension Used for showing Country,City from lat long
extension UIViewController{
func fetchCountryAndCity(location: CLLocation, completion: @escaping (String, String) -> ()) {
CLGeocoder().reverseGeocodeLocation(location) { placemarks, error in
if let error = error {
print(error)
} else if let country = placemarks?.first?.country,
let city = placemarks?.first?.locality {
import Foundation
import CoreData
class DataManager:NSObject{
// MARK: - Core Data stack
lazy var persistentContainer: NSPersistentContainer = {
let container = NSPersistentContainer(name: "MyDownloadCoreData")
//
// ChatViewController.swift
// pukkading
//
// Created by Vikas Pundora on 23/07/18.
// Copyright © 2018 Twist. All rights reserved.
//
import UIKit
import SystemConfiguration
@dilipiOSDeveloper
dilipiOSDeveloper / ChatViewController2.swift
Last active September 11, 2018 06:41
Chat page code on 11 Sep'18 ,12 pm
//
// ChatViewController.swift
// pukkading
//
// Created by Vikas Pundora on 23/07/18.
// Copyright © 2018 Twist. All rights reserved.
//
import UIKit
import SystemConfiguration
@dilipiOSDeveloper
dilipiOSDeveloper / basicCode.swift
Last active September 13, 2018 09:42
Code for checking Selected or Unselected state of CollectionView or TableView
// Code for checking when cell is selected for CollectionView
let cell = collectionView.cellForItem(at: indexPath)
if cell?.isSelected == true{
// cell is selected
}
else{
// cell is not selected
import UIKit
struct RequestType {
static let POST = "POST"
static let GET = "GET"
}
enum HtttpType: String {
case POST = "POST"
case GET = "GET"