Skip to content

Instantly share code, notes, and snippets.

@lucianomarisi
lucianomarisi / xcode-git-init.sh
Last active November 11, 2017 13:26
Script for initializing a git repository with a gitignore for Xcode (can be added to the /usr/local/bin directory)
#!/bin/bash
# Script for initializing a git repository with a gitignore for Xcode
git init
echo -e "xcuserdata\n.DS_Store" > .gitignore
git add .
git commit -m "Initial commit"
@lucianomarisi
lucianomarisi / KeychainStore.swift
Created May 24, 2017 15:27
Simple class for storing Strings in the Keychain
import Foundation
final class KeychainStore {
func string(for key: String) -> String? {
return self.readItem(forKey: key)
}
func setString(_ string: String?, for key: String) {
guard let string = string else {
@lucianomarisi
lucianomarisi / NSObject+MemoryLeak.swift
Created April 16, 2016 22:51
Extension for ensuring one instance of a class is live at any one point
extension NSObject {
// Call this when the class being debugged is initialized
func debug_ensureOnlyOneInstanceSetup() {
let type = self.dynamicType
let currentCreatedCount = createdCount(type)
assert(currentCreatedCount == 0, "More that 1 \(self) created, potential memory leak")
setCreateCount(currentCreatedCount + 1, classType: type)
}