Skip to content

Instantly share code, notes, and snippets.

View kyleve's full-sized avatar

Kyle Van Essen kyleve

View GitHub Profile
/**
Provides the ability to verify key paths at compile time.
If "keyPath" does not exist, a compile-time error will be generated.
Example:
// Verifies "isFinished" exists on "operation".
NSString *key = SQKeyPath(operation, isFinished);
// Verifies "isFinished" exists on self.
@kyleve
kyleve / gist:8367856
Last active January 2, 2016 22:09
Dynamic Linker Flags via a Build Script
1) Make Foo.xcconfig, add to project.
2) Change Xcode Project's Configurations to be based on Foo.xcconfig.
3) Add Run Script build phase.
4) Make Run Script build phase modifiy Foo.xcconfig to be something like "MY_FLAGS = "-lBar -lBaz"", etc.
5) Change "Other Linker Flags" in Build Settings to be ${MY_FLAGS}.
/**
Allows easier pushing and popping of clang warnings.
Example (Ignoring undeclared selectors):
SQClangDiagnosticPushIgnored(-Wundeclared-selector);
SEL undeclaredSelector = @selector(thisSelectorDoesNotExist:::);
SQClangDiagnosticPop;
*/
NSManagedObjectContext *context = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType];
// Crashes with an EXC_BAD_ACCESS at 0x10.
context.parentContext = nil;
@kyleve
kyleve / Init.swift
Last active February 3, 2018 23:01
// Make initialization + configuration of mutable classes (such as views) easier.
@warn_unused_result
public func Init<Type>(value : Type, @noescape block: (object: Type) throws -> Void) rethrows -> Type
{
try block(object: value)
return value
}
func example()
{
public func Synchronize(semaphore : AnyObject, @noescape block : Void throws -> Void) rethrows -> Void
{
objc_sync_enter(semaphore)
defer { objc_sync_exit(semaphore) }
try block()
}
@warn_unused_result
public func Synchronize<Type>(semaphore : AnyObject, @noescape block : Void throws -> Type) rethrows -> Type
//
// CompareEquatableProperties.swift
// ListableUI
//
// Created by Kyle Van Essen on 7/28/22.
//
import Foundation