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
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) { |
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
// Returns the managed object context for the application. | |
// If the context doesn't already exist, it is created and bound to the persistent store coordinator for the application. | |
@lazy var managedObjectContext: NSManagedObjectContext = { | |
let context = (NSManagedObjectContext() as NSManagedObjectContext?)! | |
context.persistentStoreCoordinator = self.persistentStoreCoordinator | |
return context | |
}() | |
// Returns the managed object model for the application. | |
// If the model doesn't already exist, it is created from the application's model. |
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 findLast<C : Swift.Collection where C.GeneratorType.Element : Equatable>(domain: C, value: C.GeneratorType.Element) -> C.IndexType? { | |
return reduce(enumerate(domain), nil) { (prevIndex: C.IndexType?, pair: (index: C.IndexType, elem: C.GeneratorType.Element)) -> C.IndexType? in | |
if pair.elem == value { | |
return pair.index | |
} | |
else { | |
return prevIndex | |
} | |
} | |
// It doesn't like the combine (closure) parameter: |
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 realEnumerate<C: Swift.Collection>(collection: C) -> GeneratorOf<(C.IndexType, C.GeneratorType.Element)> { | |
var i: C.IndexType = collection.startIndex | |
return GeneratorOf() { | |
if i < collection.endIndex { | |
// 'i' is flagged in comparison with "'C.IndexType' is not convertible to 'CString'". Whuh? | |
let value = (i, collection[i]) | |
i = i.successor() | |
return value | |
} |
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
// DO NOT EDIT. This file is machine-generated and constantly overwritten. | |
// Make changes to <$managedObjectClassName$>.swift instead. | |
import CoreData | |
<$if noninheritedAttributes.@count > 0$> | |
enum <$managedObjectClassName$>Attributes: String {<$foreach Attribute noninheritedAttributes do$> | |
case <$Attribute.name$> = "<$Attribute.name$>"<$endforeach do$> | |
} | |
<$endif$> |
OlderNewer