Skip to content

Instantly share code, notes, and snippets.

View gauravkeshre's full-sized avatar

Gaurav K gauravkeshre

View GitHub Profile
@gauravkeshre
gauravkeshre / Readme.md
Last active April 3, 2018 15:11
Proposal: Data Handover Mechanism among UIViewControllers

Proposal for Data handover accross ViewControllers

Passing dependencies across controllers

What

This mechanism gives us a framework (and discipline) to pass data from one conroller to another.

How does it work

Protocols

Every controller conforms to DataReciever protocol which means that it will have a property model that can be set from the caller scope.

@gauravkeshre
gauravkeshre / readme.md
Last active August 21, 2023 18:03
iOS Cocoa Touch Universal Framework Script

iOS Cocoa Touch Universal Framework Script

What

For an framework to be compatible with various devices it has to be compiled for them specifically, This script does those tasks in single shot.

How

Install Script

  1. Select Target
@gauravkeshre
gauravkeshre / static_lib_aggregate_runscript_readme.md
Last active March 29, 2018 07:30
iOS Cocoa Touch Static Library Aggregate Script

iOS Cocoa Touch Static Library Aggregate Script

What

For an framework to be compatible with various devices it has to be compiled for them specifically, This script does those tasks in single shot.

How

Install Script

Build Settings

@gauravkeshre
gauravkeshre / readme.md
Created March 29, 2018 07:44
Stores the SHA from last commit in the plist for beta app inspection purpose

Xcode Save SHA to Plist

What

Simple script to capture the last commit SHHA into plist. This script gets ignored if the code is not under git

How

Build Settings

  1. Select Target > Build Phases
@gauravkeshre
gauravkeshre / Readme.md
Last active January 13, 2019 19:47
Manage first party dependencies with Universal Dynamic Framework. Without Cocoapod and Carthage

Manage first-party dependencies with Universal Dynamic Framework without using cocoapods or carthrage

Requirement

Should be able to setup your first party dependencies (dynamic frameworks) and the updates must reflect without re-integrating the new .framework repeatedly

Considerations

cocoapod, carthage are great when you have third party or well-defined first party dependencies, without doubt. But there will be instances when you don't want to create a git repository for a dependency or the dependency just sits in your project and you just want the.framework file instead of subproject.

@gauravkeshre
gauravkeshre / Readme.md
Last active January 13, 2019 19:48
Integrating custom frameworks using private pods without creating a new git repo

Integrating custom frameworks using private pods without creating a new git repo

Read this if

  1. You have broken your app into custom frameworks (reusable features)
  2. Integrated these private frameworks manually.
  3. Integrated these private frameworks using Custom Scripts
  4. You want to move them to private cocoapods but don't want to create privatee repositories
  5. You don't mind keeping (organizing) the frameworks in the main project
@gauravkeshre
gauravkeshre / Readme-Code.md
Last active January 13, 2019 19:49
Recently, I came accross an excellent validate and visualize Regular Expressions. I thought of implementing a small problem using regex and validate it from there.

Check if a string is a number using regex

Recently, I came accross this excellent tool to validate and visualize Regular Expressions. I thought of implementing a small problem using regex and validate it from there.

REGEX: ^\s*\d*([.]\d+|\d+[.]|\d+[eE]\d+){0,1}\d*\s*$

 func isNumber(_ s: String) -> Bool {
@gauravkeshre
gauravkeshre / Readme-Code.md
Last active January 13, 2019 19:50
Dictionary Subscripts - Clever way to access data from dictionary

Dictionary custom subscript for cleaner access

This is more than common use case where we access some data from dictionary defined as [String: Any?].

Most of the time we are aware of the data type in advance we allpy force cast (not me) or optional binding to finally access the data.

Consider you have a user object coming in as a Dictionary<String: Any> and you have to access the gender.

Now this gender could have {0, 1, 2}, {"m", "f", "o"} or {"male", "female", "other"}

@gauravkeshre
gauravkeshre / Readme-Code.md
Last active January 13, 2019 19:51
A simple playground gist that demonstrates how we can leverage performSelector for achieving basic polling-like behaviour in swift.

How to implement polling using performSelector

import Foundation
import PlaygroundSupport

PlaygroundPage.current.needsIndefiniteExecution = true
@gauravkeshre
gauravkeshre / Readme-Code.md
Last active January 13, 2019 19:52
# Binary representation of a FixedWidthInteger with padding zeros.

Binary representation of a FixedWidthInteger with padding zeros

An initializer in String class String(5, radix: 2) creates a string which is a binary representation of 5 as : 101 But it will not give a padded version (for obvious and good reasons) like 00000101 or 00000000 00000101 which may be desirable in some cases

Here are two approaches of achieving this :

1.