Skip to content

Instantly share code, notes, and snippets.

View kenechiokolo's full-sized avatar

KC Okolo kenechiokolo

View GitHub Profile
// 1. Before
static var titles: [String] {
var i = 0
var titles: [String] = []
while let categoryTitle = StudyCategory(rawValue: i)?.title {
titles.append(categoryTitle)
i += 1
}
return titles
}
//: Playground - noun: a place where people can play
func uniqueString(name: String, list: [String]) -> String {
var suffix = 0
func nameCheck(n: String) -> String {
var localName = n
guard list.contains(localName) else { return n }
suffix += 1
localName = name + "-\(suffix)"
@kenechiokolo
kenechiokolo / RequestManager.swift
Last active April 24, 2017 17:46
APISearchControllerTutorial using delegation instead of KVO
//
// RequestManager.swift
// APISearchControllerTutorial
//
// Created by Kc on 24/03/2016.
// Copyright © 2016 Kenechi Okolo. All rights reserved.
//
import Foundation
import Alamofire
@kenechiokolo
kenechiokolo / ViewController.swift
Created February 22, 2016 14:01
Code for NSTimer Tutorial
//
// ViewController.swift
// NSTimerTutorial
//
// Created by Kc on 22/02/2016.
// Copyright © 2016 Kenechi Okolo. All rights reserved.
//
import UIKit
@kenechiokolo
kenechiokolo / OurTableViewController.swift
Last active March 18, 2016 21:01
Dynamic TableView Tutorial Example
//
// OurTableViewController.swift
// TableView Tutorial
//
// Created by Kc on 02/11/2015.
// Copyright © 2015 Kenechi Okolo. All rights reserved.
//
import UIKit
@kenechiokolo
kenechiokolo / Code for CoreData Video Walkthrough
Created August 26, 2015 16:13
CoreData to CSV file code walkthrough
// MARK: Export functions
func createExportString() -> String {
var date: NSDate? = NSDate()
var worktime: Double?
var breaktime: Double?
var studyRate: Double?
var studyQuota: Double?
var hoursLeft: Int?
var distractionCount: Int?
@kenechiokolo
kenechiokolo / HangmanLexicon.java
Created April 17, 2015 12:13
Hangman Lexicon (CS106A Assignment 4)
/*
* File: HangmanLexicon.java
* -------------------------
* This file contains a stub implementation of the HangmanLexicon
* class that you will reimplement for Part III of the assignment.
*/
import java.util.*;
import java.io.*;
@kenechiokolo
kenechiokolo / HangmanCanvas.java
Created April 17, 2015 12:12
Hangman Canvas (CS106A Assignment 4)
/*
* File: HangmanCanvas.java
* ------------------------
* This file keeps track of the Hangman display.
*/
import acm.graphics.*;
public class HangmanCanvas extends GCanvas {
@kenechiokolo
kenechiokolo / Hangman_II.java
Created April 17, 2015 12:10
Hangman Game (Complete) (CS106A Assignment)
import acm.graphics.*;
import acm.program.*;
import acm.util.*;
import java.awt.*;
public class Hangman_II extends ConsoleProgram {
private final static int N_HANGMAN_PARTS = 8; // number of parts to draw to complete hangman drawing
@kenechiokolo
kenechiokolo / Hangman Game (Console Game)
Created April 12, 2015 14:36
Hangman Game (CS106A Assignment 4 Part I)
import acm.graphics.*;
import acm.program.*;
import acm.util.*;
import java.awt.*;
public class Hangman_II extends ConsoleProgram {
public HangmanLexicon lexicon = new HangmanLexicon(); // creates an object of type HangmanLexicon
private final static int N_HANGMAN_PARTS = 8; // number of parts to draw to complete hangman drawing