Movatterモバイル変換


[0]ホーム

URL:


Skip to content
Search Gists
Sign in Sign up

Instantly share code, notes, and snippets.

View kyleve's full-sized avatar

Kyle Van Essen kyleve

UI Systems EM at@square
View GitHub Profile
//
// CompareEquatableProperties.swift
// ListableUI
//
// Created by Kyle Van Essen on 7/28/22.
//
import Foundation
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
kyleve /Init.swift
Last activeFebruary 3, 2018 23:01
// 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()
{
NSManagedObjectContext *context = [[NSManagedObjectContextalloc]initWithConcurrencyType:NSMainQueueConcurrencyType];
// Crashes with an EXC_BAD_ACCESS at 0x10.
context.parentContext =nil;
/**
Allows easier pushing and popping of clang warnings.
Example (Ignoring undeclared selectors):
SQClangDiagnosticPushIgnored(-Wundeclared-selector);
SEL undeclaredSelector = @selector(thisSelectorDoesNotExist:::);
SQClangDiagnosticPop;
*/
@kyleve
kyleve /gist:8367856
Last activeJanuary 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}.
/**
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.

[8]ページ先頭

©2009-2025 Movatter.jp