Skip to content

Instantly share code, notes, and snippets.

Jasdev Singh jasdev

Block or report user

Report or block jasdev

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jasdev
jasdev / FoundationErrorWrapper.swift
Created Jul 14, 2016
An attempt at a protocol that can imply the present of specific cases
View FoundationErrorWrapper.swift
import Foundation
public protocol FoundationErrorWrapper: ErrorProtocol {
static func wrappingError(_ error: NSError) -> Self
}
enum SomeError: ErrorProtocol, FoundationErrorWrapper {
case a
case wrappingError(NSError)
}
@jasdev
jasdev / CharacterSet+StringLiteralConvertible.swift
Created Jun 30, 2016
CharacterSet StringLiteralConvertible
View CharacterSet+StringLiteralConvertible.swift
extension CharacterSet: StringLiteralConvertible, ExtendedGraphemeClusterLiteralConvertible {
public init(stringLiteral value: String) {
self.init(charactersIn: value)
}
public init(extendedGraphemeClusterLiteral value: ExtendedGraphemeClusterType) {
self.init(charactersIn: value)
}
public init(unicodeScalarLiteral value: UnicodeScalarType) {
@jasdev
jasdev / AppDefault.swift
Last active Aug 13, 2016
Swift nonmutating Example
View AppDefault.swift
import Foundation
enum AppDefault {
case APIServer, runMode, homeDirectory, reactHost
var stringValue: String? {
get {
return NSUserDefaults.standardUserDefaults().stringForKey(String(self))
}
View SampleViewController.swift
final class SampleViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let button = UIButton(type: .System)
// ...
button.addTarget(self, action: #selector(SampleViewController.buttonTapped(_:)), forControlEvents: .TouchUpInside)
View SampleViewController.swift
final class SampleViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let button = UIButton(type: .System)
// ...
button.addTarget(self, action: #selector(SampleViewController.buttonTapped(_:)), forControlEvents: .TouchUpInside)
@jasdev
jasdev / Operation.swift
Created Feb 15, 2016
NSOperation Subclass with KVO Notifications
View Operation.swift
class Operation: NSOperation {
override var asynchronous: Bool {
return true
}
private var _executing = false {
willSet {
willChangeValueForKey("isExecuting")
}
@jasdev
jasdev / CustomCell.swift
Last active Jul 6, 2018
An approach to safer UITableViewCell and UICollectionViewCell reuse
View CustomCell.swift
class CustomCell: UITableViewCell, Reusable {
class var reuseIdentifier: String {
return "customCell"
}
}
class SupaHotCustomCell: CustomCell {
override class var reuseIdentifier: String {
return "supaHotCustomCell"
}
@jasdev
jasdev / AppDelegate.swift
Last active Sep 5, 2015
A Tour of UIUserNotificationAction
View AppDelegate.swift
import UIKit
enum Notifications {
enum Categories: String {
case Message
}
enum Actions: String {
case RemindMeLater
case Reply
@jasdev
jasdev / BKLNSwiftPresenters.md
Last active Aug 29, 2015 — forked from marcdown/BKLNSwiftPresenters.md
Brooklyn Swift Developers Meetup Presenters
View BKLNSwiftPresenters.md
@jasdev
jasdev / UpperCaseLetter.swift
Created Aug 12, 2015
Swift 2.0 gist to quickly determine if a String contains an uppercase alphabetical character
View UpperCaseLetter.swift
extension String {
func containsUpperCaseLetter() -> Bool {
let beginCodePoint = Character("A").unicodeScalarCodePoint()
let endCodePoint = Character("Z").unicodeScalarCodePoint()
for scalar in self.unicodeScalars {
if case beginCodePoint...endCodePoint = scalar.value {
return true
}
}
You can’t perform that action at this time.