This file contains 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
import Foundation | |
internal final class MulticastDelegate<T> { | |
private var delegates = [Weak]() | |
func add(_ delegate: T) { | |
if Mirror(reflecting: delegate).subjectType is AnyClass { | |
let weakValue = Weak(value: delegate as AnyObject) | |
guard delegates.index(of: weakValue) == nil else { | |
return |
This file contains 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
#import <objc/runtime.h> | |
static void SwizzleClassMethod(Class klass, SEL original, SEL new) | |
{ | |
Method origMethod = class_getClassMethod(klass, original); | |
Method newMethod = class_getClassMethod(klass, new); | |
if (class_addMethod(klass, original, method_getImplementation(newMethod), method_getTypeEncoding(newMethod))) { | |
class_replaceMethod(klass, new, method_getImplementation(origMethod), method_getTypeEncoding(origMethod)); |
This file contains 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
UIModalPresentationStyle | iPhone | iPad | |
---|---|---|---|
.fullScreen | YES | YES | |
.pageSheet | YES | NO | |
.formSheet | YES | NO | |
.currentContext | YES | YES | |
.custom | NO | NO | |
.overFullScreen | NO | NO | |
.overCurrentContext | NO | NO | |
.blurOverFullScreen | only on tvOS - N/A | N/A | |
.popover | YES | NO |
This file contains 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
#!/usr/bin/env ruby | |
device_types_output = `xcrun simctl list devicetypes` | |
device_types = device_types_output.scan /(.*) \((.*)\)/ | |
runtimes_output = `xcrun simctl list runtimes` | |
runtimes = runtimes_output.scan /(.*) \(.*\) \((com.apple[^)]+)\)$/ | |
devices_output = `xcrun simctl list devices` | |
devices = devices_output.scan /\s\s\s\s(.*) \(([^)]+)\) (.*)/ |
This file contains 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
import Foundation | |
import Combine | |
@propertyWrapper | |
final class UserDefault<Wrapped>: NSObject, ObservableObject { | |
typealias Validator = (Wrapped) -> (Wrapped) | |
private let suite: UserDefaults | |
private let key: String |
This file contains 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
/* This SnapshotHelper class should be compatible with SnapshotHelper.swift version 1.2 */ | |
@import Foundation; | |
@import XCTest; | |
@interface SnapshotHelper : NSObject | |
- (instancetype)initWithApp:(XCUIApplication*)app; | |
- (void)snapshot:(NSString*)name waitForLoadingIndicator:(BOOL)wait; |
This file contains 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
func fetchUserId() -> Observable<String> { | |
return create{ (observer) -> Disposable in | |
Client.fetchUserId() { [unowned self] | |
(userId: String?, err: ErrorType?) -> Void in | |
if let _ = err{ | |
observer.on(Event.Error(err!)) | |
} else { | |
observer.on(Event.Next(userId)) | |
observer.on(Event.Completed) | |
} |
This file contains 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
.fullScreen | YES | YES | |
---|---|---|---|
.pageSheet | YES | NO | |
.formSheet | YES | NO | |
.currentContext | YES | YES | |
.custom | NO | NO | |
.overFullScreen | NO | NO | |
.overCurrentContext | NO | NO | |
.blurOverFullScreen | only on tvOS - N/A | N/A | |
.popover | YES | NO |
This file contains 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
<% flash.each do |type, message| %> | |
<div class="alert <%= bootstrap_class_for(type) %> fade in"> | |
<button class="close" data-dismiss="alert">×</button> | |
<%= message %> | |
</div> | |
<% end %> |
This file contains 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
# nil? can be used on any Ruby object. It returns true only if the object is nil. | |
nil.nil? # => true | |
[].nil? # => false | |
{}.nil? # => false | |
"".nil? # => false | |
" ".nil? # => false | |
true.nil? # => false | |
# empty? can be used on some Ruby objects including Arrays, Hashes and Strings. It returns true only if the object's length is zero. | |
nil.empty? # NoMethodError: undefined method `empty?' for nil:NilClass |
OlderNewer