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)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated | |
{ | |
[[UIApplication sharedApplication] setStatusBarHidden:NO]; | |
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES]; | |
} |
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
Class sportsFeedManager = (Class <RPSportsBoundryProtocol>)[RPInteractor sportsFeedManager]; | |
[sportsFeedManager yahooSportsFeedWithCompletion:^(NSArray *sportsFeeds, NSError *error) | |
{ | |
if (error) | |
{ | |
// TODO: Handle the error; | |
} | |
else | |
{ |
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 SwizzleClassMethod(Class c, SEL orig, SEL new) { | |
Method origMethod = class_getClassMethod(c, orig); | |
Method newMethod = class_getClassMethod(c, new); | |
c = object_getClass((id)c); | |
if(class_addMethod(c, orig, method_getImplementation(newMethod), method_getTypeEncoding(newMethod))) | |
class_replaceMethod(c, new, method_getImplementation(origMethod), method_getTypeEncoding(origMethod)); | |
else |
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)parseLoginData:(NSData *)responseData withCompletionBlock:(MJDataSourceCompletionBlock)completionBlock | |
{ | |
[self parseData:responseData withCompletionBlock:^(id response, MJError *error) | |
{ | |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) | |
{ | |
MJLoginResponse *loginResponse = [[MJLoginResponse alloc] initWithLoginResponse:response]; | |
dispatch_async(dispatch_get_main_queue(), ^(void) | |
{ |
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
CAAnimationGroup *animationsGroup = [CAAnimationGroup animation]; | |
CATransition *t = [CATransition animation]; | |
t.type = kCATransitionPush; | |
t.subtype = kCATransitionFromRight; | |
t.duration = 1.0f; | |
id currentContents = _layer.contents; | |
_layer.contents = (id)([UIImage imageNamed:@"image2.jpg"].CGImage); | |
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
protocol Foo { | |
typealias T: Hashable | |
var foos: [T] { get } | |
} | |
struct Bar<T: Equatable>: Foo { | |
let foos: [T] | |
init(foos: [T]) { |
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 fetchData(request: NSURLRequest) -> SignalProducer<[Foo], Error> { | |
return foosFromServer(request).flatMapError {_ in //network failed deal with it} | |
.flatMapLatest { parseFoos($0).flatMapError {_ in //parse failed deal with it} } | |
.flatMapLatest { persistFoos($0).flatMapError {_ in //persist failed deal with it} } | |
.flatMapError { error in loadFoosFromCache().mapError {_ in error} } | |
} |
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
1. The work should only be started when we spend more than 0.5s in the ViewController | |
2. Check if there is data in the cache | |
2.1 Success: Show it and start an internet request if the cache is outdated | |
2.1.1 Success: Show the data | |
2.1.2 Failed: Silently fail | |
2.2 Fail: Try to get data from the internet | |
2.2.1 Success: Show it | |
2.2.2 Fail: Show the error | |
3. Every 5 minutes start internet request check, if cache is outdated && ViewController is visible | |
3.1 Success: Show the data |
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
class TableDataSource: UITableViewDataSource { | |
let viewModels: [ViewModel] | |
init(viewModels: [ViewModel]) { | |
self.viewModels = viewModels | |
} | |
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { | |
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
networkResult.map { $0.count }.map(String.init).startWithNext {[weak self] numberOfResults in | |
self?.myLabel = numberOfResults | |
} |