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
// | |
// NSArray+Conjunction.h | |
// Typesetter | |
// | |
// Created by Brent Royal-Gordon on 2/11/12. | |
// Copyright (c) 2012 Architechies. All rights reserved. | |
// | |
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
// | |
// NSObject+TsPropertyListRepresentation.h | |
// PressKit | |
// | |
// Created by Brent Royal-Gordon on 3/6/13. | |
// Copyright (c) 2013 Novelty Publishers. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |
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
// There's a lot that bothers me about NSFileWrappers: | |
// * Directories are mutable, but regular files and symlinks aren't. | |
// * You can't change from one type to another. | |
// * ...but the -readFromURL:... method can violate both of these rules. Probably. | |
// * Wrappers include a .filename, but this is only relevant to their containing folders. | |
// * Wrappers include a .preferredFilename, but this is only relevant to the folder they're being added to, and doesn't matter after being added. | |
// * There's no way to replace a file wrapper in a directory, except by removing the old one and then adding the new one. | |
// Here's how I would design a file wrapper replacement. | |
typedef NS_ENUM(NSUInteger, GBSFileWrapperType) { |
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/Foundation.h> | |
@interface Foo : NSObject | |
@property NSUInteger bar; | |
- (void)doWithBar; | |
@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
+ (void)postsForBooks:(NSArray*)books completion:(void (^)(NSArray *, NSError *))completion { | |
[self postsForBook:books.firstObject otherBooks:[books subarrayWithRange:NSMakeRange(1, books.count - 1)] completion:completion]; | |
} | |
+ (void)postsForBook:(UHUBook *)book otherBooks:(NSArray*)others completion:(void (^)(NSArray *, NSError *))completion { | |
if(book == nil) { | |
completion(@[], nil); | |
} |
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
// | |
// NSProgress+Ignored.h | |
// Uhura | |
// | |
// Created by Brent Royal-Gordon on 4/4/14. | |
// Copyright (c) 2014 Architechies. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |
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
// | |
// NSAttributedString+format.m | |
// Chatterbox | |
// | |
// Created by Brent Royal-Gordon on 2/7/14. | |
// Copyright (c) 2014 Architechies. All rights reserved. | |
// | |
#import "NSAttributedString+format.h" |
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
struct Statics { | |
static var foo: Int = 0 | |
} | |
class var foo: Int { | |
get { return Statics.foo } | |
set { Statics.foo = newValue } | |
} |
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
func first<S: Sequence> (seq: S) -> S.GeneratorType.Element? { | |
var gen = seq.generate() | |
return gen.next() | |
} | |
func first<S: Sequence> (seq: S, #count: Int) -> Slice<S.GeneratorType.Element> { | |
var gen = seq.generate() | |
var list = Slice<S.GeneratorType.Element>() | |
while list.count < count { |
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
func result() -> A { | |
var result : A = dispatch_sync(resultQueue, { | |
return self.result | |
}) | |
return result | |
} | |
func dispatch_sync<R> (queue: dispatch_queue_t, block: Void -> R ) -> R { | |
var result: R! | |
dispatch_sync(queue) { |