Instantly share code, notes, and snippets.
UI Systems EM at@square
- Square, Inc.
- San Francisco
- 20:08
(UTC -07:00) - @kyleve@mastodon.online
kyleve /CompareEquatableProperties.swift
CreatedJuly 29, 2022 00:56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
// | |
// CompareEquatableProperties.swift | |
// ListableUI | |
// | |
// Created by Kyle Van Essen on 7/28/22. | |
// | |
import Foundation |
kyleve /Synchronize.swift
Last activeJanuary 4, 2016 09:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
publicfunc Synchronize(semaphore:AnyObject,@noescape block:Voidthrows->Void)rethrows->Void | |
{ | |
objc_sync_enter(semaphore) | |
defer{objc_sync_exit(semaphore)} | |
tryblock() | |
} | |
@warn_unused_result | |
publicfunc Synchronize<Type>(semaphore:AnyObject,@noescape block:Voidthrows->Type)rethrows->Type |
kyleve /Init.swift
Last activeFebruary 3, 2018 23:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
// Make initialization + configuration of mutable classes (such as views) easier. | |
@warn_unused_result | |
publicfunc Init<Type>(value:Type,@noescape block:(object:Type)throws->Void)rethrows->Type | |
{ | |
tryblock(object: value) | |
return value | |
} | |
func example() | |
{ |
kyleve /gist:36b984d422cdc309447c
CreatedNovember 17, 2014 19:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
NSManagedObjectContext *context = [[NSManagedObjectContextalloc]initWithConcurrencyType:NSMainQueueConcurrencyType]; | |
// Crashes with an EXC_BAD_ACCESS at 0x10. | |
context.parentContext =nil; |
kyleve /gist:373d7951baf9cea69584
CreatedMay 2, 2014 07:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
/** | |
Allows easier pushing and popping of clang warnings. | |
Example (Ignoring undeclared selectors): | |
SQClangDiagnosticPushIgnored(-Wundeclared-selector); | |
SEL undeclaredSelector = @selector(thisSelectorDoesNotExist:::); | |
SQClangDiagnosticPop; | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
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}. |
kyleve /gist:8213806
CreatedJanuary 2, 2014 01:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
/** | |
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. |