- Turning an eager, pure computation into a lazy one:
RACSequence
,RACSignal
- Side-effecting work that is safe to perform multiple times:
RACSignal
,RACCommand
- Side-effecting work that is safe to perform multiple times serially, but not concurrently:
RACCommand
,RefCount()
RACScheduler
would seem to apply here, but execution could become interleaved and thus not serial
- Side-effecting work that should only be performed once, then memoized:
RACMulticastConnection
with aRACReplaySubject
,RACSequence
- Enabling/disabling a UI based on whether work can be performed:
RACCommand
,RACReplaySubject
- Replaying is a Good Idea™ because this information may arrive before the UI is ready for it
- Updating a UI with information about work in progress:
RACCommand
,RACSubject
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
/* | |
* Calling math.h functions like `floor` and `floorf` on CGFloat variables | |
* becomes problematic when compiling the same code for both 32-bit and | |
* 64-bit platforms, since CGFloat is double on 64-bit, float on 32-bit. | |
* Hence, if you compile with -Wconversion set, `floorf` will give a warning | |
* on 64-bit, while `floor` gives a warning on 32-bit. | |
* | |
* Here's a suggested implementation of an architecture-independent `floor` | |
* function, written using plain old function overloading which is enabled | |
* using the `__attribute__((overloadable))` Clang language extension. |
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
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { | |
// Horrible HACK for bug in UITextView where it won't scroll to the new line after pressing enter in the text view. | |
// I feel dirty for having to write this. Buggy at least within iOS 7.0 - 7.1b1. | |
if (PSPDFIsUIKitFlatMode() && [text isEqualToString:@"\n"] && range.location == textView.text.length) { | |
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)); | |
dispatch_after(popTime, dispatch_get_main_queue(), ^{ | |
CGPoint contentOffset = textView.contentOffset; | |
CGFloat fontSize = textView.font.pointSize; | |
if (textView.contentSize.height - fontSize > textView.bounds.size.height) { | |
contentOffset.y += fontSize + 2.f; // add spacing |
- First, plug in an 8GB (or bigger) USB drive, and use Disk Utility to erase it
- If you use the default settings, you should wind up with a blank drive at
/Volumes/Untitled
.
With that volume in place, and with the macOS installer sitting in /Applications/Install\ macOS\ [VERSION].app
,
run the following command in your terminal to create a bootable install media (for Sierra):
sudo /Applications/Install\ macOS\ Sierra.app/Contents/Resources/createinstallmedia --volume /Volumes/Untitled --applicationpath /Applications/Install\ macOS\ Sierra.app --nointeraction
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
// Taken from http://PSPDFKit.com. This snippet is under public domain. | |
#define UIKitVersionNumber_iOS_7_0 0xB57 | |
BOOL PSPDFIsUIKitFlatMode(void) { | |
static BOOL isUIKitFlatMode = NO; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
// We get the modern UIKit if system is running >= iOS 7 and we were linked with >= SDK 7. | |
if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_7_0) { | |
isUIKitFlatMode = (NSVersionOfLinkTimeLibrary("UIKit") >> 16) >= UIKitVersionNumber_iOS_7_0; | |
} |
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
typedef struct { | |
int girlfriend; | |
} holder; | |
typedef struct { | |
holder a; | |
} toplevel; | |
typedef struct { | |
int this; |
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
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context | |
{ | |
if (object == self && context == self.kvoContext) { | |
((void (^)(void)) @{ | |
@"addresses": ^{ self.peep.address = [self dictionaryForArrayOfValues:self.addresses]; }, | |
@"emails": ^{ self.peep.email = [self dictionaryForArrayOfValues:self.emails]; }, | |
}[keyPath] ?: ^{})(); | |
} | |
else if (object == self.peep && context == self.kvoContext) { | |
((void (^)(void)) @{ |
To form a parent-child relationship:
- Send the
-addChildViewController:
message to the parent with the child as the parameter. This will send the-willMoveToParentViewController:
message to the child with the parent as the parameter. - Add the child view controller's
view
as a subview to the parent view controller'sview
. - Send the
-didMoveToParentViewController:
message to the child with the parent as the parameter.
For example,
[parent addChildViewController:child];
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
// Taken from the commercial iOS PDF framework http://pspdfkit.com. | |
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved. | |
// Licensed under MIT (http://opensource.org/licenses/MIT) | |
// | |
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it. | |
// PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit. | |
#import <objc/runtime.h> | |
#import <objc/message.h> |