Skip to content

Instantly share code, notes, and snippets.

@jonathan-beebe
jonathan-beebe / swift-to-objc-bool-bridge.m
Created Dec 22, 2016
Bridging an optional bool from Swift to Objective-C
View swift-to-objc-bool-bridge.m
@implementation MyObjcClass
. . .
if(mySwiftClassInstance.hasFeatureBridged == nil) {
// handle nil case
}
else if(mySwiftClassInstance.hasFeatureBridged boolValue] == YES) {
// handle true case
}
@jonathan-beebe
jonathan-beebe / Garmin Connect IQ Custom Drawable
Last active Dec 13, 2021
Garmin Connect IQ Custom Drawable
View Garmin Connect IQ Custom Drawable
A sample of creating a custom drawable, both in xml and via code.
@jonathan-beebe
jonathan-beebe / README.md
Last active Apr 13, 2021
git: Find all merged ancestors branches and create commands to delete them.
View README.md

To find all ancestor branches

./get_ancestor_branches.sh

To create the delete commands for all ancestor branches and echo them as text (not invoking them)

@jonathan-beebe
jonathan-beebe / async_xctest.swift
Created Jul 20, 2016
A template for async swift tests
View async_xctest.swift
import XCTest
@testable import {AppTarget}
class TestCase: XCTestCase {
func testCode() {
let expectation = expectationWithDescription("test description")
var result: Bool?
// Setup the the test here
@jonathan-beebe
jonathan-beebe / fix-nokogiri.sh
Created Jul 14, 2016
Fixing nokogiri on OS X 10.12 El Capitan
View fix-nokogiri.sh
gem install nokogiri -v '1.6.8' -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2
@jonathan-beebe
jonathan-beebe / LocalizableButton.swift
Last active Oct 24, 2017
Localizable views in xib or storyboards
View LocalizableButton.swift
import UIKit
/// Implements a UIButton that can be localized within a xib or storyboard.
/// To render a localized string set a “User defined runtime attribute” on
/// the view with a key path of `localizableStringKey` and a string value of
/// the localized string key.
class LocalizableButton: UIButton {
var localizableStringKey: String? {
didSet {
@jonathan-beebe
jonathan-beebe / async_helpers.swift
Created May 16, 2016
Helpers to make dispach_* code in Swift a bit more concise.
View async_helpers.swift
import Foundation
func async(callback:(Void -> Void)) {
dispatch_async(dispatch_get_main_queue(), { () -> Void in
callback()
})
}
func after(delay:Double, closure:Void->Void) {
dispatch_after(
@jonathan-beebe
jonathan-beebe / UICTContentSizeCategory
Created Feb 5, 2016
UICTContentSizeCategory logs for each category
View UICTContentSizeCategory
```
UICTContentSizeCategoryXS
Caption 1 = {size: 11pts, weight:normal}
default = {size: 13pts, weight:normal}
Body = {size: 14pts, weight:normal}
Subhead = {size: 12pts, weight:normal}
Title 1 = {size: 25pts, weight:normal}
@jonathan-beebe
jonathan-beebe / vundle_swift_vim_instructions.md
Last active Nov 30, 2021
Using Apple’s Swift vim plugin with Vundle
View vundle_swift_vim_instructions.md

Source of original vim config: https://github.com/apple/swift/tree/master/utils/vim

# use `svn checkout…` to grab just the subfolder from github
svn checkout https://github.com/apple/swift/trunk/utils/vim
# rename to something a bit more specific
mv vim vim-swift
cd vim-swift
rm -rf .svn
# init git
@jonathan-beebe
jonathan-beebe / curried_functions.swift
Last active Dec 21, 2015
curried functions in Swift
View curried_functions.swift
// Here is a manually curried function.
// maxA takes an int and returns a function, maxB, that takes an int and returns an int.
func maxA(a:Int) -> (Int) -> Int {
func maxB(b:Int) -> Int {
return a > b ? a : b
}
return maxB
}