Skip to content

Instantly share code, notes, and snippets.

View kandelvijaya's full-sized avatar
🎯
Focusing

Vijaya Prakash Kandel kandelvijaya

🎯
Focusing
View GitHub Profile
@kandelvijaya
kandelvijaya / .gitAliases
Created August 16, 2016 09:16
My GithubAlias
alias gs="git status -s"
alias gd="git diff"
alias ga="git add"
alias gbr="git branch"
alias gc="git checkout "
alias gcm="git commit -m "
alias gcam="git commit -a -m"
alias gcamd="date > .dummy-commit && git commit -a -m 'Dummy Commit'"
alias gp="git push"
alias glog="git log --oneline --decorate --graph"

Evolution is predominant. Struggle for Survival applies to just anything that you see. Swift Programming Language is not an exception. Swift continues to change, evolve and mature over time. We can keep our feet wet, migrating year after year to Swift X version. I would. If it strives to be better. This years, Swift 2 -> Swift 3 was little more than a mini project. We saw lots of changes. For this edition, we will focus on [AnyObject: NSObject], which became [AnyHashable: Any]. So does JSON, NSArray and NSDictionary. But why?

We will dive deep, bear with me.

AnyObject -> Any

  1. Swift focuses on using Value Types / immutable type in all cases possible. Foundation in Objective-C, has in other hand, all reference type. Classes. Which will be imported into reference type in swift.
  2. AnyObject is idiomatically ObjectiveC flavored and is reference type.
  3. Swift is platform independent, it had to move away from relying on ObjectiveC idioms and its runtime. Hence AnyObject had to be replace with
@kandelvijaya
kandelvijaya / PrecisionTimer.swift
Created October 24, 2016 20:41
Precision Timing in iOS/OSX/Swift
//: Playground - noun: a place where code can play
import UIKit
//Most precise time keeper
// for more information on the benchmarks go to www.kandelvijaya.com
func timeBlockWithMach(_ block: () -> Void) -> TimeInterval {
var info = mach_timebase_info()
guard mach_timebase_info(&info) == KERN_SUCCESS else { return -1 }
import Foundation
struct RandomStringGenerator {
func createRandomWord(with wordLength: Int) -> String {
let chars = (0..<wordLength).map{_ in return String(randomChar()) }
return chars.reduce(""){ $0 + $1 }
}
func randomChar() -> Character {
{
"6.4.5-xcode11": "https://github.com/usabilla/usabilla-u4a-ios-swift-sdk/releases/download/v6.4.5-Xcode-11.4-beta-3/Carthage.framework.zip",
}
@kandelvijaya
kandelvijaya / LoadingIndicatorMorphingToSettingsView.swift
Created May 23, 2020 09:34
Weird behavior when using transition with views that have animations.
//
// LoadingIndicator.swift
// AnimationTransitionDemo
//
// Created by Vijaya Prakash Kandel on 5/23/20.
// Copyright © 2020 Vijaya Prakash Kandel. All rights reserved.
//
import SwiftUI