Skip to content

Instantly share code, notes, and snippets.

View chaitanyaSoni96's full-sized avatar

Chaitanya Soni chaitanyaSoni96

View GitHub Profile
lazy var persistentContainer: NSPersistentContainer = {
/*
The persistent container for the application. This implementation
creates and returns a container, having loaded the store for the
application to it. This property is optional since there are legitimate
error conditions that could cause the creation of the store to fail.
*/
let container = NSPersistentContainer(name: "CoreDataExample")
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
let start = CFAbsoluteTimeGetCurrent()
// run your work
let diff = CFAbsoluteTimeGetCurrent() - start
print("Took \(diff) seconds")
@chaitanyaSoni96
chaitanyaSoni96 / ViewController.swift
Created June 21, 2020 12:05
Alamofire implementation for generic api calls in swift
import UIKit
import Alamofire
import iOSDropDown
class ViewController: UIViewController {
//Variables
@IBOutlet weak var dropDownTxtField: DropDown!
@chaitanyaSoni96
chaitanyaSoni96 / APIClient.swift
Created June 21, 2020 12:03
URLSession class for generic api calls in swift
//
// PEAPIUtilityExt.swift
// ProcializeEvents
//
// Created by Chaitanya Soni on 21/06/20.
// Copyright © 2020 Chaitanya Soni. All rights reserved.
//
import Foundation
You can make a deep copy of your object via the following extension functions:
import UIKit
import Realm
import RealmSwift
protocol RealmListDetachable {
func detached() -> Self
}
//
// SharedExtensions.swift
// Aansim 2019
//
// Created by chaitanyaSoni on 7/19/19.
// Copyright © 2019 Creative Plus. All rights reserved.
//
import Foundation
@chaitanyaSoni96
chaitanyaSoni96 / BusinessManager
Created June 14, 2019 11:12
CSKolodaViewController Extensions
//
// CSKolodaViewControllerBusinessManager.swift
// SellQwik
//
// Created by Admin on 18/04/19.
//
import Foundation
extension CSKolodaViewController: BusinessManagerDelegate{
@chaitanyaSoni96
chaitanyaSoni96 / HexToUIColor1
Created June 14, 2019 11:12
UIColor Extensions
A great Swift implementation (updated for Xcode 7) using extensions, pulled together from a variety of different answers and places. You will also need the string extensions at the end.
Use:
let hexColor = UIColor(hex: "#00FF00")
NOTE: I added an option for 2 additional digits to the end of the standard 6 digit hex value for an alpha channel (pass in value of 00-99). If this offends you, just remove it. You could implement it to pass in an optional alpha parameter.
@chaitanyaSoni96
chaitanyaSoni96 / CSKolodaViewController.txt
Created June 14, 2019 11:09
viewController For koloada cards swipe
//
// CSKolodaViewController.swift
// SellQwik
//
// Created by Chaitanya Soni on 16/04/19.
//
import Foundation
import Koloda
import moa
-(void)method:(NSString *)str withCompletion:(void (^)(NSArray* arr))callback{
NSMutableArray *a = [NSArray new];
[a addObject:str];
callback(a);
}
[YourClassName method:@"" withCompletion:^(NSArray *arr) {
NSLog(arr.count)