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
@implementation KIFUITestActor (BruteForceEscape) | |
- (void)tapViewsWithAccessibilityLabels:(NSArray *)labels whileWaitingForViewWithAccessibilityLabel:(NSString *)targetLabel | |
{ | |
[self runBlock:^KIFTestStepResult(NSError **error) { | |
for (NSString *label in labels) { | |
UIView *view; | |
UIAccessibilityElement *element; |
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
@implementation KIFUITestActor (TableView) | |
- (BOOL)deleteAnyVisibleTableViewCell | |
{ | |
UIAccessibilityElement *element = [[UIApplication sharedApplication] accessibilityElementMatchingBlock:^BOOL(UIAccessibilityElement *element) { | |
return [element.accessibilityLabel hasPrefix:@"Delete "]; | |
}]; | |
if (!element) { | |
return 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
import Foundation | |
struct FilteringGenerator<T where T:Generator> : Generator { | |
let test:(T.Element) -> Bool | |
var generator:T | |
init(_ generator:T, _ test: (T.Element) -> Bool) { | |
self.test = test | |
self.generator = generator | |
} |
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; | |
@interface PrimeEnumerator : NSObject<NSFastEnumeration> | |
- (NSArray *)knownPrimes; | |
@end | |
@interface PrimeEnumerator () | |
@property (nonatomic, strong) NSMutableArray *primes; | |
@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
// Good idea or Bad idea? | |
// Lets say you have to call some API with lots of parameters that you don't control | |
// Like this http://developer.android.com/reference/android/text/StaticLayout.html#StaticLayout(java.lang.CharSequence, int, int, android.text.TextPaint, int, android.text.Layout.Alignment, float, float, boolean, android.text.TextUtils.TruncateAt, int) | |
// Do you prefer Option #1 or Option #2? Is Option #2 a terrible idea? | |
// I suppose Option #3 could be to wrap it in a Builder | |
class Foo { |
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 Cocoa | |
struct PartialConstraint { | |
private let item:AnyObject | |
private let attribute:NSLayoutAttribute | |
private let multiplier:CGFloat? | |
private let constant:CGFloat? | |
private func constraintWith(partial:PartialConstraint, relation:NSLayoutRelation) -> NSLayoutConstraint { | |
assert(multiplier == nil && constant == nil, "Cannot define multiplier or constant on LHS.") |
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 <UIKit/UIKit.h> | |
#import <objc/runtime.h> | |
#ifdef DEBUG | |
void SEViewAlertForUnsafeBackgroundCalls() { | |
NSLog(@"----------------------------------------------------------------------------------"); | |
NSLog(@" "); | |
NSLog(@"Background call to setAnimationsEnabled: detected. This method is not thread safe."); | |
NSLog(@"Set a breakpoint at SEUIViewDidSetAnimationsOffMainThread to inspect this call."); |
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/python | |
# fix-xcode | |
# Rob Napier <[email protected]> | |
# Script to link in all your old SDKs every time you upgrade Xcode | |
# Create a directory called /SDKs (or modify source_path). | |
# Under it, put all the platform directories: | |
# MacOSX.platform iPhoneOS.platform iPhoneSimulator.platform | |
# Under those, store the SDKs: |
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/swift | |
import Foundation | |
let url = NSURL(string: "http://not-a-real-host")! | |
let request = NSURLRequest(URL: url) | |
var response:NSURLResponse? = nil | |
var error:NSError? = nil | |
NSURLConnection.sendSynchronousRequest(request, returningResponse: &response, error: &error) |
OlderNewer