Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Hemang hemangshah

🎯
Focusing
Block or report user

Report or block hemangshah

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
@hemangshah
hemangshah / LoginErrorHandling.playground
Created Dec 24, 2018
Trying to implement the best way to handle custom errors through in a login flow (as an example).
View LoginErrorHandling.playground
import UIKit
// ---- [LoginManager.swift] ---- starts
enum LoginError: Error {
case minUserNameLength(String), minPasswordLength(String), invalidUserName(String), invalidPassword(String)
}
enum LoginResult {
case result([String: Any])
}
@hemangshah
hemangshah / AppDelegate.swift
Created Dec 12, 2018
Managing Local & Remote Notifications from different classes
View AppDelegate.swift
// [START receive_message]
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
// If you are receiving a notification message while your app is in the background,
// this callback will not be fired till the user taps on the notification launching the application.
// TODO: Handle data of notification
// With swizzling disabled you must let Messaging know about the message, for Analytics
// Messaging.messaging().appDidReceiveMessage(userInfo)
// Print full message.
print(userInfo)
@hemangshah
hemangshah / NetworkMonitor.swift
Created Apr 15, 2018
NetworkMonitor can be used to check for the Internet Connection
View NetworkMonitor.swift
import UIKit
import Reachability
class NetworkMonitor {
static let shared = NetworkMonitor()
internal var isNetworkAvailable : Bool {
get {
return networkStatus != .none
}
}
@hemangshah
hemangshah / MyLabel.swift
Created Aug 24, 2017
Observe Text changes in UILabel in Swift
View MyLabel.swift
class MyLabel: UILabel {
var textWillChange:((_ oldText: String?)->())? = nil
var textDidChange:((_ newText: String?)->())? = nil
override var text: String? {
willSet {
if textWillChange != nil {
textWillChange!(self.text)
}
}
didSet {
@hemangshah
hemangshah / StackPlayground.playground
Last active Aug 10, 2017
This is the demonstration of Stack in Swift. I have used the default functions to handle the Stack operations.
View StackPlayground.playground
//: Playground - noun: a place where people can play
import Foundation
class Stack {
static let list = Stack.init()
private var items = Array<Any>()
internal var limit = 5
//MARK: Push
You can’t perform that action at this time.