Skip to content

Instantly share code, notes, and snippets.

View jspahrsummers's full-sized avatar

Justin Spahr-Summers jspahrsummers

View GitHub Profile
@jspahrsummers
jspahrsummers / iflet.m
Last active August 29, 2015 14:16 — forked from cdzombak/iflet.m
#import <Foundation/Foundation.h>
#define iflet(LHS, RHS) \
for (id obj_ = (RHS); obj_ != nil;) \
for (LHS = (obj_ ?: (RHS)); obj_ != nil; obj_ = nil)
int main(int argc, char *argv[]) {
@autoreleasepool {
NSString *x = nil;
NSString *y = @"y";
[NSWindow ex_patchInstanceSelector: @selector(sendEvent:) withReplacementBlock: ^(EXPatchIMP *patch) {
return ^(NSEvent *event) {
NSWindow *window = (__bridge NSWindow *) patch->self;
if (window != self.window && [event type] == NSLeftMouseUp && [window isKeyWindow]) {
/* The last view seen */
static NSView *lastView = nil;
NSPoint point = [window.contentView convertPoint: [event locationInWindow] fromView: nil];
NSView *hitView = [window.contentView hitTest: point];
- (RACSignal*)friendsId
{
return [self enqueueWithCursor:-1];
}
- (RACSignal*)enqueueWithCursor:(NSInteger)cursor
{
@weakify(self);
return [[self idsAtCursor:cursor]
// Map each `next` (there should only be one) to a new signal.
- (id)initWithFrame:(CGRect)rect {
self = [super initWithFrame:rect];
if (self == nil) return nil;
[self initializeComponent];
RAC(self.title.text) = RACAble(self.viewModel.model.title);
RAC(self.userAndOrgTiles.itemSource) = RACAble(self.viewModel.userAndOrgTiles);
self.loginButton.rac_command = self.viewModel.showLoginCommand;