Skip to content

Instantly share code, notes, and snippets.

View corysullivan's full-sized avatar

Cory Sullivan corysullivan

View GitHub Profile
@corysullivan
corysullivan / json
Created May 3, 2020 13:50
AUS Configuration
{}
//
// DraggingValidator.swift
// Stash
//
// Created by Cory Sullivan on 2019-03-09.
// Copyright © 2019 Cory Sullivan. All rights reserved.
//
import Cocoa
/// A thread safe class for managing an array of objects of a given type. The sequence holds
/// weak references to the contained objects, allowing them to be deallocated and
/// removed automatically. Order is maintained within the sequence.
class Listener<T> {
private let listeners: NSHashTable<AnyObject> = NSHashTable.weakObjects()
private let lockingQueue = DispatchQueue(label: "com.livelike.listenerSynchronizer", attributes: .concurrent)
func addListener(_ listener: T) {
lockingQueue.async(flags: .barrier) { [weak self] in
self?.listeners.add(listener as AnyObject)
- (void)configureDefaults
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *currencyCode = [[NSLocale currentLocale] objectForKey:NSLocaleCurrencyCode];
NSNumber *selectedRow;
//On first open select the first item if a portfolio does exist
selectedRow = ([Portfolio MR_countOfEntities] > 0) ? @1 : @-1;
NSDictionary *standardDefaults = @{SBI_DEFAULT_CURRENCY:currencyCode,
kSelectedRow:selectedRow,