Skip to content

Instantly share code, notes, and snippets.

View elefantel's full-sized avatar

Mpendulo Ndlovu elefantel

  • MetaMask
  • Cape Town, WC
  • 19:42 (UTC +02:00)
View GitHub Profile
public enum Storyboard: String {
case Analytics, Dashboard, Reporting, Transactions
var instance: UIStoryboard {
return UIStoryboard(name: self.name, bundle: nil)
}
var name: String {
return self.rawValue
}
//navigate within same module
func navigateToPayment() {
let storyboard = UIStoryboard(name: "Transactions", bundle: nil)
if let controller = storyboard.instantiateViewController(withIdentifier: "PaymentViewController") as? PaymentViewController {
self.navigationController.pushViewController(controller, animated: true)
}
}
//navigate to different module
func navigateToPortfolioDashboard() {
public extension UIViewController {
class var storyboardID: String {
return "\(self)"
}
public func instantiateViewController<T: UIViewController>(viewControllerClass: T.Type, inStoryboard: String, ofModule: Bundle?) -> T {
let storyboard = UIStoryboard(name: inStoryboard, bundle: ofModule)
return storyboard.instantiateViewController(withIdentifier: viewControllerClass.storyboardID) as! T
}
@elefantel
elefantel / clone_repos.sh
Created March 20, 2017 21:48
Clone git repositories
#!/bin/bash
clone_encryption_sdk() {
echo '--------------------------------------------------'
echo 'Cloning EncryptionSDK'
echo '--------------------------------------------------'
git clone https://github.com/XYCompany/EncryptionSDK.git
}
clone_utilities() {
@elefantel
elefantel / carthage_update.sh
Created March 20, 2017 21:53
Run carthage update on each module
#!/bin/bash
update_encryption_sdk() {
echo '--------------------------------------------------'
echo 'Running Carthage update on EncryptionSDK'
echo '--------------------------------------------------'
cd ../encryption-sdk/
run_carthage_update
}
#!/bin/bash
HARDWARE="iphonesimulator"
CONFIGURATION="Debug"
for i in "$@"; do
if [ "$i" = "all" ]
then
echo "====== Building all Frameworks ======"
xcodebuild -project encryption-sdk/EncryptionSDK.xcodeproj -configuration $CONFIGURATION -sdk $HARDWARE -scheme EncryptionSDK
@elefantel
elefantel / master_script.sh
Created March 20, 2017 22:09
Clone, carthage update, and build
#!/bin/bash
clone_repos() {
./clone_repos.sh all
}
carthage_update() {
./carthage_update.sh all
}
//navigate within same module
func navigateToPayment() {
if let controller = AppStoryboard.Transactions.viewController(viewControllerClass: PaymentViewController.self) {
self.navigationController.pushViewController(controller, animated: true)
}
}
//navigate to different module
func navigateToPortfolioDashboard() {
let portfolioModule = Bundle(for: DashboardViewController.self)
@elefantel
elefantel / KeyboardObservingTableView.swift
Created May 2, 2017 16:04
Tableview that observes changes in keyboard display
protocol KeyboardDisplayChangeProtocol {
func addKeyboardObserver(on view: UIView)
func removeKeyboardObserver()
}
public class KBTableView: UITableView {
weak var view: UIView?
public func addKeyboardObserver(on view: UIView) {
@elefantel
elefantel / CustomCell.swift
Created May 2, 2017 16:18
A custom cell with a title label, a text field and an error label
class CustomCell: UITableViewCell {
var textField: UITextField!
var titleLabel: UILabel!
var errorLabel: UILabel!
static var identifier: String {
return "\(CustomCell.self)"
}