Skip to content

Instantly share code, notes, and snippets.

@shankartshinde
shankartshinde / UIDeviceExtension.swift
Last active December 9, 2022 15:16
UIDevice as extension to determine current type of device/simulator in Swift
//
// UIDeviceExtension.swift
//
// Created by shankars on 3/15/19.
// Copyright © 2019 shankars. All rights reserved.
//
import Foundation
import UIKit
@shankartshinde
shankartshinde / PY0101EN-1-2-Strings.ipynb
Created February 20, 2019 08:55
Created on Cognitive Class Labs
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@shankartshinde
shankartshinde / PY0101EN-1-1-Types.ipynb
Created February 20, 2019 08:31
Created on Cognitive Class Labs
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
//: Playground - noun: a place where people can play
import Foundation
struct Swifter {
let fullName: String
let id: Int
let twitter: URL
init(fullName: String, id: Int, twitter: URL) { // default struct initializer
//
// ViewController.swift
// ContactApp
//
// Created by Yugan on 08/05/18.
// Copyright © 2018 Yugan. All rights reserved.
//
import UIKit
print("Q:1:")
let val = 10.2
print("\(val) of type \(val.description)")
var numbers = [1,2,3]
numbers+=[4]
print(numbers)
@shankartshinde
shankartshinde / iterateArray.swift
Created May 8, 2018 06:39
Iterate two dimensional array in swift
import UIKit
let twoDiamentionalArray = [
["Shankar","Archana","Amol","Shivaji","Ketan"],
["Mumbai","Pune","Dehli","Hyderabad"],
["Elephant","Cat","Dog","Cow","Tiger","Lion"]
]
let sectionNames = ["Best Friends","Beautiful Cities","Faviorate Animal"]
@shankartshinde
shankartshinde / Register TableView Cell or nib
Last active May 8, 2018 08:04
How to register a cell for UITableViewCell reuse
let cellIdentifier = "CellIdentifier"
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
tableView.register(UITableViewCell.self, forCellReuseIdentifier: cellIdentifier)
}
OR
import UIKit
@IBDesignable
class CustomImageView: UIImageView {
@IBInspectable var borderColor: UIColor? = UIColor.clear {
didSet {
layer.borderColor = self.borderColor?.cgColor
}
}