Skip to content

Instantly share code, notes, and snippets.

View bobspryn's full-sized avatar
🌴
On vacation

Bob Spryn bobspryn

🌴
On vacation
View GitHub Profile
@bobspryn
bobspryn / MFMessageComposeViewController.m
Created March 4, 2014 01:23
ReactiveCocoa enabled MFMessageComposeViewController
//
// MFMessageComposeViewController+RAC.m
// Three Cents
//
// Created by Bob Spryn on 3/3/14.
// Copyright (c) 2014 Three Cents, Inc. All rights reserved.
//
#import "MFMessageComposeViewController+RAC.h"
#import <objc/objc-runtime.h>
@bobspryn
bobspryn / TwitterAuth.m
Created March 19, 2014 04:20
TwitterAuth.m
self.accountStore = [[ACAccountStore alloc] init];
self.pickTwitterAccountCommand = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(ACAccount *account) {
return [RACSignal return:account];
}];
// Returns an error we handle when they cancel picking from multiple twitter accounts
RACSignal *cancelledPickingTwitterAccount = [[[self.pickTwitterAccountCommand.executionSignals switchToLatest]
filter:^BOOL(ACAccount *account) {
return account == nil;
- (void)viewDidLoad
{
[super viewDidLoad];
DeviceSettingsHeaderView *headerView = [[DeviceSettingsHeaderView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, self.tableView.bounds.size.width, DEVICE_HEADER_HEIGHT)];
// don't need this with the current code
// RACSignal *newDevice = [RACObserve(self, device) ignore: nil];
// When the battery level changes, update the string
//
// TCAnswerDetailTitleDetailCell.m
// Three Cents
//
// Created by Bob Spryn on 4/11/13.
// Copyright (c) 2013 Three Cents, Inc. All rights reserved.
//
#import "TCAnswerDetailTitleDetailCell.h"
- (void) setupButtons {
NSMutableArray *buttons = [@[] mutableCopy];
for (NSUInteger i = 0; i < TCInviteSectionFacebook; i++) {
TCInviteFriendsTabButton *button = [[TCInviteFriendsTabButton alloc] init];
button.translatesAutoresizingMaskIntoConstraints = NO;
button.viewModel = self.viewModel;
button.section = i;
[buttons addObject:button];
[self.view addSubview:button];
}
@bobspryn
bobspryn / signalForSelector.m
Last active April 18, 2016 10:20
signalForSelector.m
- (void)viewDidLoad
{
[super viewDidLoad];
@weakify(self);
self.exploreSearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, mTCTableViewFrameWidth, 44)];
self.exploreSearchBar.placeholder = @"Search";
self.exploreSearchBar.delegate = self;
[self.exploreSearchBar setBackgroundImage:[UIImage squareImageWithColor:mTCLightTanColor dimension:1] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
@bobspryn
bobspryn / changesets.m
Created April 11, 2014 22:30
changesets.m
- (void) init {
[super init];
self.activityItemsTableChangeSignal = [[[RACSignal zip:@[[RACObserve(self, activityItems) ignore:nil],
[RACObserve(self, previousActivityItems) ignore:nil]]]
skip:1]
reduceEach:^id (NSOrderedSet *activityItems, NSOrderedSet *previousActivityItems){
return [self generateChangeSetsForSection:kTCTableUpdateSectionActivity withNewObjects:activityItems fromOldObjects:previousActivityItems];
}];
}
@bobspryn
bobspryn / inputs.m
Created June 15, 2014 06:04
inputs.m
// delegate methods
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
}
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}
// block based callbacks
[TCAPI getCategoriesModifiedSince:date onComplete:^(NSArray *objects, RKObjectRequestOperation *operation, NSError *error) {
}];
// target action
- (IBAction)doneAction:(id)sender {
- (void) viewDidLoad {
[super viewDidLoad];
self.fetchUserMenuDataCommand = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(id input) {
return [TCAPI fetchUserMenuData];
}];
RAC(self, menuData) = [self.fetchUserMenuDataCommand.executionSignals switchToLatest];
RACSignal *userIsLoggedInSignal = [[[[NSNotificationCenter defaultCenter] rac_addObserverForName:kUserLoggedOutNotification object:nil]
@interface MYTwitterLookupViewModel: NSObject
@property (nonatomic, assign, readonly, getter=isUsernameValid) BOOL usernameValid;
@property (nonatomic, strong, readonly) NSString *userFullName;
@property (nonatomic, strong, readonly) UIImage *userAvatarImage;
@property (nonatomic, strong, readonly) NSArray *tweets;
@property (nonatomic, assign, readonly) BOOL allTweetsLoaded;
@property (nonatomic, strong, readwrite) NSString *username;