Skip to content

Instantly share code, notes, and snippets.

import UIKit
enum AppUrl {
static var baseUrl: String {
#if DEBUG
return "http://saurabhdev.com"
#elseif STAGGING
return "http://saurabhstagging.com"
#elseif RELEASE
return "http://saurabhlive.com"
class ViewController: UIViewController {
@IBOutlet var tfName: UITextField!
@IBOutlet var tfAddress: UITextField!
@IBOutlet var tfPhone: UITextField!
@IBOutlet var tfEmail: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
import Foundation
import CoreData
import UIKit
class DatabaseManager {
static var shared = DatabaseManager() // Created a shared instance so that we can use save function in the ViewController class
let context = (UIApplication.shared.delegate as? AppDelegate)?.persistentContainer.viewContext // Creating a context for Core Data
// When you add CoreData to your project, Core Data stack is already added in App Delegate which contains all CRUD operations
class ViewController: UIViewController {
// Lazy stored property
lazy var memoryUsage: MemoryUsage = {
return MemoryUsage()
}()
// Stored property
var memoryUsage1 = MemoryUsage()
override func viewDidLoad() {
super.viewDidLoad()
}
// Create a structure
struct MemoryUsage {
func checkUsage() {
print ("Some value")
}
}
// Create a structure
struct MemoryUsage {
func checkUsage() {
print ("Some value")
}
}
if let pdfUrl = Bundle.main.url(forResource: "sample", withExtension: "pdf", subdirectory: nil, localization: nil) {
do {
let url = URL(string: "https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf")
let data = try Data(contentsOf: url!)
let sharedContent = [data]
let printController = UIPrintInteractionController.shared
let printInfo = UIPrintInfo(dictionary:nil)
printInfo.outputType = UIPrintInfoOutputType.general
print (closureExample("Saurabh", "Dutta"))
}
var closureExample = { (firstName: String, lastName: String ) -> (String) in
return "\(firstName) \(lastName)"
}
@saurabh23july
saurabh23july / gist:2076233c13e1026e6a7eaab80e2a1078
Created September 6, 2016 05:17
Get method in AFnetworking !
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager GET:@"http://www.HistoricalGurudwaras.com/Services/GuruSahib.svc/GetGuruSahibs" parameters:nil progress:nil success:^(NSURLSessionTask *task, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(NSURLSessionTask *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
- (IBAction)menuAction:(id)sender {
[[NSNotificationCenter defaultCenter]
postNotificationName:@"SideMenu"
object:self];
[UIView beginAnimations:@"Side" context:nil];
[UIView setAnimationDuration:0.5];
if(!ismenu)
{