Skip to content

Instantly share code, notes, and snippets.

View anuraagdjain's full-sized avatar

Anuraag D Jain anuraagdjain

View GitHub Profile
@anuraagdjain
anuraagdjain / AppDelegate.swift
Created April 4, 2017 04:49
Adding Core Data to existing project. iOS 10 below and above supported with latest Swift 3.X syntax.
import CoreData
//MARK: - Core Data Stack
let dbName = "My_Data_Model_Name"
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
self.saveContext()
}
private lazy var applicationDocumentsDirectory: URL = {
// The directory the application uses to store the Core Data store file. This code uses a directory named in the application's documents Application Support directory.
@anuraagdjain
anuraagdjain / ViewController.swift
Created February 22, 2017 15:45
A basic implementation of JSQMessagingViewController in Swift 3.0. Part 1/2
//
// ViewController.swift
// Messenger
//
// Created by Anuraag Jain on 05/12/16.
// Copyright © 2016 Anuraag. All rights reserved.
// Part 2 : https://gist.github.com/anuraagdjain/b049fe19b15c02901b50bd6a82d2d147/edit
import UIKit
@anuraagdjain
anuraagdjain / MessageDetailsViewController.swift
Last active February 22, 2017 15:45
A basic implementation of JSQMessagingViewController in Swift 3.0. Part 2/2
//
// MessageDetailsViewController.swift
// Messenger
//
// Created by Anuraag Jain on 05/12/16.
// Copyright © 2016 Anuraag. All rights reserved.
// Part 1 : https://gist.github.com/anuraagdjain/e874a8409225356233d56df435b96335
import UIKit
import MobileCoreServices
@anuraagdjain
anuraagdjain / ViewController.swift
Last active February 14, 2017 10:39
Twitter Like Pull effect iOS
//Source: https://github.com/ariok/TB_TwitterUI
@IBOutlet weak var headerView: UIView!
@IBOutlet weak var scrollView: UIScrollView!
override viewDidLoad(){
scrollView.delegate = self
/*
Add below code for testing purposes.
scrollView.contentSize = CGSize(width: self.view.frame.size.width, height: 1024)
@anuraagdjain
anuraagdjain / ViewController.swift
Created February 7, 2017 06:59
Adding refresh for tableView
//Declare
@IBOutlet weak var tableView:UITableView!
var refreshControl = UIRefreshControl()
//Adding in viewDidLoad()
refreshControl.addTarget(self, action: #selector(ViewController.refreshEvents), for: .valueChanged)
tableView.addSubView(refreshControl)
//refreshEvents function
func refreshEvents(){
@anuraagdjain
anuraagdjain / Info.plist
Created February 7, 2017 06:54
Status bar light content
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
//In AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
UIApplication.shared.statusBarStyle = .lightContent //White colored status.
return true
}
@anuraagdjain
anuraagdjain / Info.plist
Created February 7, 2017 06:51
Disable App Transport Security
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>