Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jsorge
jsorge / nibless.swift
Created May 7, 2018 20:14
Nibless View Controller
//: Playground - noun: a place where people can play
import UIKit
class ViewController: UIViewController {
init() {
super.init(nibName: nil, bundle: nil)
}
@available(*, unavailable, message: "Loading this view controller from a nib is unsupported.")
{
"product_detail_frame_v1": {
"brand_name_span": "<span class='zu_header_sm zu_gray_2'>The Bubble Case</span>",
"image_gallery": {
"images": ["https://zcdn.global.ssl.fastly.net/images/cache/product/{width}x{height}/248870/zu49336847_main_tm1500147799.jpg"]
},
"love": {
"is_lovable": 1,
"is_loved_by_customer": 0,
"loved_path": "/product/49336847/love",
@jsorge
jsorge / notification-sample.swift
Last active July 10, 2017 04:57
How to make Notifications type safe
import UIKit
struct CustomNotification: NotificationDescriptor {
struct Output {
let name: String
let type: String
}
typealias Payload = Output
let noteName = Notification.Name("CustomNotificationPosted")
//: Playground - noun: a place where people can play
import UIKit
class VC {
var dataSource: DataSource?
func viewDidLoad() {
let items = dataSource?.numberOfItemsIn(section: 9) ?? -1
print("There are \(items) items")
@jsorge
jsorge / foo.m
Last active April 26, 2017 04:27
Notification.Name in Obj-C
- (void)createNotification {
NSNotification *note = [[NSNotification alloc] initWithName:JMSFoo.noteName object:nil userInfo:nil];
[[NSNotificationCenter defaultCenter] postNotification: note];
}
import UIKit
protocol ResponderTest: class {
var name: String { get }
func printName() -> String
}
extension ResponderTest where Self: NSObject {
func printName() -> String {
return name
@jsorge
jsorge / swift-map.swift
Last active December 1, 2015 19:04
Trying to work out how to remove these nasty loops...
//: Playground - noun: a place where people can play
import UIKit
struct Person {
let name: String
let isCool: Bool?
}
struct Department {
//
// MyViewController.h
//
// Created by Jared Sorge on 6/14/15.
// Copyright (c) 2015 Taphouse Software. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface MyViewController : UIViewController
### Keybase proof
I hereby claim:
* I am jsorge on github.
* I am jsorge (https://keybase.io/jsorge) on keybase.
* I have a public key whose fingerprint is 624A 8463 510C 943E 6790 1C9F 2FDD 3FE1 3981 C642
To claim this, I am signing this object:
@jsorge
jsorge / JMSBTCentral.h
Last active August 29, 2015 14:00
CoreBluetooth Helpers
//
// JMSBTCentral.h
// CP130_HW2_Bluetooth
//
// Created by Jared Sorge on 4/20/14.
// Copyright (c) 2014 jsorge. All rights reserved.
//
#import <Foundation/Foundation.h>