This file contains hidden or 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
// Create an RBTCentralManager | |
self.manager = [[RBTCentralManager alloc] init]; | |
// Scan and connect to all the peripherals | |
RACDisposable *disposable = [[[[[self.manager.stateSignal | |
takeUntilBlock:^BOOL(NSNumber *state) { | |
return (state.integerValue == CBCentralManagerStatePoweredOn); | |
}] then:^RACSignal *{ | |
return [self.manager scanForPeripheralsWithServices:nil options:nil]; | |
}] reduceEach:^(CBPeripheral *peripheral, NSDictionary *advertisementData, NSNumber *RSSI) { |
This file contains hidden or 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
XEP-0115 (Capabilities) | |
XEP-0054 (vCard) | |
XEP-0153 (Avatars) | |
XEP-0092 (Software Version) | |
XEP-0085 (Chat State) | |
XEP-0199 (Ping) | |
XEP-0203 (Delay) | |
XEP-0095 (Stream Initiation) | |
XEP-0096 (SI File Transfer) | |
XEP-0065 (SOCKS5 Bytestreams) |
This file contains hidden or 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 void (^FGOConfigurationBlock)(id); | |
@interface FGOManagedObjectContextStack : NSObject | |
- (id)initWithModelName:(NSString *)modelName; | |
- (RACSignal *)save; | |
#pragma mark - Fetching | |
- (RACSignal *)fetchImmediatelyWithRequest:(NSFetchRequest *)request; |
This file contains hidden or 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
- (id)insertObjectOfEntityName:(NSString *)entityName configure:(void(^)(id))block | |
{ | |
NSAssert([NSThread isMainThread], @"Wrong thread bro"); | |
NSManagedObject *object = [NSEntityDescription insertNewObjectForEntityForName:entityName inManagedObjectContext:self.mainQueueContext]; | |
if (block) block(object); | |
NSError *error = nil; | |
if (![self.mainQueueContext save:&error]) { | |
NSLog(@"Error saving MOC: %@", error); | |
} | |
return object; |
This file contains hidden or 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
+ (NSDate *)compileDate | |
{ | |
BOOL (^stringContainsQuestionMark)(NSString *) = ^BOOL (NSString *string) { | |
return [string rangeOfString:@"?"].location != NSNotFound; | |
}; | |
NSMutableString *dateString = @(__DATE__).mutableCopy; | |
NSString *timeString = @(__TIME__); | |
if (stringContainsQuestionMark(dateString) || stringContainsQuestionMark(timeString)) { | |
return nil; |
This file contains hidden or 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 NSManagedObjectContext (INAdditions) | |
- (RACSignal *)in_saveChanges | |
{ | |
return [[RACSignal startEagerlyWithScheduler:RACScheduler.scheduler block:^(id<RACSubscriber> subscriber) { | |
__block void (^recursiveBlock)(NSManagedObjectContext *); | |
recursiveBlock = [^(NSManagedObjectContext *context) { | |
[context performBlock:^{ | |
NSError *error = nil; | |
[context save:&error]; |
This file contains hidden or 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
NSString *sanitizedString = [URLString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; | |
NSURL *URL = [NSURL URLWithString:sanitizedString]; |
This file contains hidden or 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
// | |
// FGOManagedObjectContextStack.h | |
// | |
// Created by Indragie Karunaratne on 2012-12-23. | |
// | |
#import <Foundation/Foundation.h> | |
typedef void (^FGOConfigurationBlock)(id); |
This file contains hidden or 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)fetchWithRequest:(NSFetchRequest *)request | |
completion:(void(^)(NSArray *results, NSError *error))handler | |
{ | |
[request setResultType:NSManagedObjectIDResultType]; | |
void (^executeHandler)(NSArray *, NSError *) = ^(NSArray *results, NSError *error){ | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
if (handler) handler(results, error); | |
}); | |
}; | |
[self.backgroundContext performBlock:^{ |
This file contains hidden or 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
// In an NSSplitView subclass | |
- (void)drawDividerInRect:(NSRect)rect | |
{ | |
[super drawDividerInRect:NSIntegralRect(rect)]; | |
} | |
// In NSSplitViewDelegate implementation | |
- (CGFloat)splitView:(NSSplitView *)splitView constrainSplitPosition:(CGFloat)proposedPosition ofSubviewAt:(NSInteger)dividerIndex |